Commit 028018dc authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

Clang: Clear left-over preambles after crash



...otherwise they accumulate in the temporary directory.

Change-Id: I0841f3d168f30f559fc718d2825dd3e800515074
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
parent 8224c1c9
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment