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()
|
ConnectionClient::ConnectionClient()
|
||||||
{
|
{
|
||||||
processAliveTimer.setInterval(10000);
|
processAliveTimer.setInterval(10000);
|
||||||
|
resetTemporaryDir();
|
||||||
|
|
||||||
static const bool startAliveTimer = !qEnvironmentVariableIntValue("QTC_CLANG_NO_ALIVE_TIMER");
|
static const bool startAliveTimer = !qEnvironmentVariableIntValue("QTC_CLANG_NO_ALIVE_TIMER");
|
||||||
|
|
||||||
@@ -113,9 +114,7 @@ QProcessEnvironment ConnectionClient::processEnvironment() const
|
|||||||
|
|
||||||
const QTemporaryDir &ConnectionClient::temporaryDirectory() const
|
const QTemporaryDir &ConnectionClient::temporaryDirectory() const
|
||||||
{
|
{
|
||||||
static QTemporaryDir temporaryDirectory(QDir::tempPath() + QStringLiteral("/qtc-clang-XXXXXX"));
|
return *temporaryDirectory_.data();
|
||||||
|
|
||||||
return temporaryDirectory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LinePrefixer &ConnectionClient::stdErrPrefixer()
|
LinePrefixer &ConnectionClient::stdErrPrefixer()
|
||||||
@@ -147,6 +146,7 @@ void ConnectionClient::restartProcessAsynchronously()
|
|||||||
{
|
{
|
||||||
if (!processIsStarting) {
|
if (!processIsStarting) {
|
||||||
finishProcess(std::move(process_));
|
finishProcess(std::move(process_));
|
||||||
|
resetTemporaryDir(); // clear left-over preambles
|
||||||
|
|
||||||
startProcessAndConnectToServerAsynchronously();
|
startProcessAndConnectToServerAsynchronously();
|
||||||
}
|
}
|
||||||
@@ -218,6 +218,12 @@ void ConnectionClient::printStandardError()
|
|||||||
qDebug("%s", stdErrPrefixer_.prefix(process_->readAllStandardError()).constData());
|
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()
|
void ConnectionClient::connectLocalSocketConnected()
|
||||||
{
|
{
|
||||||
connect(&localSocket,
|
connect(&localSocket,
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
#include <QTemporaryDir>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -102,6 +104,8 @@ private:
|
|||||||
void printStandardOutput();
|
void printStandardOutput();
|
||||||
void printStandardError();
|
void printStandardError();
|
||||||
|
|
||||||
|
void resetTemporaryDir();
|
||||||
|
|
||||||
void connectLocalSocketConnected();
|
void connectLocalSocketConnected();
|
||||||
void connectLocalSocketDisconnected();
|
void connectLocalSocketDisconnected();
|
||||||
void connectProcessFinished(QProcess *process) const;
|
void connectProcessFinished(QProcess *process) const;
|
||||||
@@ -121,6 +125,7 @@ private:
|
|||||||
|
|
||||||
mutable std::unique_ptr<QProcess> process_;
|
mutable std::unique_ptr<QProcess> process_;
|
||||||
QLocalSocket localSocket;
|
QLocalSocket localSocket;
|
||||||
|
QScopedPointer<QTemporaryDir> temporaryDirectory_;
|
||||||
QTimer processAliveTimer;
|
QTimer processAliveTimer;
|
||||||
QString processPath_;
|
QString processPath_;
|
||||||
bool isAliveTimerResetted = false;
|
bool isAliveTimerResetted = false;
|
||||||
|
Reference in New Issue
Block a user