forked from qt-creator/qt-creator
Clang: Clear left-over preambles after crash
...otherwise they accumulate in the temporary directory. Change-Id: I0841f3d168f30f559fc718d2825dd3e800515074 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -43,6 +43,7 @@ namespace ClangBackEnd {
|
||||
ConnectionClient::ConnectionClient()
|
||||
{
|
||||
processAliveTimer.setInterval(10000);
|
||||
resetTemporaryDir();
|
||||
|
||||
static const bool startAliveTimer = !qEnvironmentVariableIntValue("QTC_CLANG_NO_ALIVE_TIMER");
|
||||
|
||||
@@ -113,9 +114,7 @@ QProcessEnvironment ConnectionClient::processEnvironment() const
|
||||
|
||||
const QTemporaryDir &ConnectionClient::temporaryDirectory() const
|
||||
{
|
||||
static QTemporaryDir temporaryDirectory(QDir::tempPath() + QStringLiteral("/qtc-clang-XXXXXX"));
|
||||
|
||||
return temporaryDirectory;
|
||||
return *temporaryDirectory_.data();
|
||||
}
|
||||
|
||||
LinePrefixer &ConnectionClient::stdErrPrefixer()
|
||||
@@ -147,6 +146,7 @@ void ConnectionClient::restartProcessAsynchronously()
|
||||
{
|
||||
if (!processIsStarting) {
|
||||
finishProcess(std::move(process_));
|
||||
resetTemporaryDir(); // clear left-over preambles
|
||||
|
||||
startProcessAndConnectToServerAsynchronously();
|
||||
}
|
||||
@@ -218,6 +218,12 @@ void ConnectionClient::printStandardError()
|
||||
qDebug("%s", stdErrPrefixer_.prefix(process_->readAllStandardError()).constData());
|
||||
}
|
||||
|
||||
void ConnectionClient::resetTemporaryDir()
|
||||
{
|
||||
const QString templatePath = QDir::tempPath() + QStringLiteral("/qtc-clang-XXXXXX");
|
||||
temporaryDirectory_.reset(new QTemporaryDir(templatePath));
|
||||
}
|
||||
|
||||
void ConnectionClient::connectLocalSocketConnected()
|
||||
{
|
||||
connect(&localSocket,
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <QLocalSocket>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QScopedPointer>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -102,6 +104,8 @@ private:
|
||||
void printStandardOutput();
|
||||
void printStandardError();
|
||||
|
||||
void resetTemporaryDir();
|
||||
|
||||
void connectLocalSocketConnected();
|
||||
void connectLocalSocketDisconnected();
|
||||
void connectProcessFinished(QProcess *process) const;
|
||||
@@ -121,6 +125,7 @@ private:
|
||||
|
||||
mutable std::unique_ptr<QProcess> process_;
|
||||
QLocalSocket localSocket;
|
||||
QScopedPointer<QTemporaryDir> temporaryDirectory_;
|
||||
QTimer processAliveTimer;
|
||||
QString processPath_;
|
||||
bool isAliveTimerResetted = false;
|
||||
|
Reference in New Issue
Block a user