diff options
author | Marco Bubke <marco.bubke@qt.io> | 2016-08-17 15:29:37 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2017-11-28 15:08:58 +0000 |
commit | f70bf3d2d16be3f4a7812bd0352da70fb7e0fa3b (patch) | |
tree | b22b54b5208093bed790f2b8b9d3728a7389b2f4 /src/libs/clangsupport/connectionclient.h | |
parent | 45c667d52cffdd4bfd01f89e9794aef6f5f7298b (diff) | |
download | qt-creator-f70bf3d2d16be3f4a7812bd0352da70fb7e0fa3b.tar.gz |
Clang: Move QLocalServer in ConnectionClient
Before the QLocalServer was in the ConnectionServer so more than one
client could connect to the server. But we never used that possibility
which made the hand shaking much more difficult. It is now moved
in the client, so that there is always a QLocalServer.
Change-Id: Ifa357074b0c0809434c49d23b1cee38496f72f43
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/libs/clangsupport/connectionclient.h')
-rw-r--r-- | src/libs/clangsupport/connectionclient.h | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/src/libs/clangsupport/connectionclient.h b/src/libs/clangsupport/connectionclient.h index cfa7a67b2f..6cd79956f5 100644 --- a/src/libs/clangsupport/connectionclient.h +++ b/src/libs/clangsupport/connectionclient.h @@ -27,14 +27,15 @@ #include "clangcodemodelserverproxy.h" #include "lineprefixer.h" +#include "processcreator.h" -#include <utils/temporarydirectory.h> - +#include <QLocalServer> #include <QLocalSocket> #include <QProcessEnvironment> #include <QScopedPointer> #include <QTemporaryDir> +#include <future> #include <memory> QT_BEGIN_NAMESPACE @@ -53,10 +54,10 @@ class CLANGSUPPORT_EXPORT ConnectionClient : public QObject Q_OBJECT public: - ConnectionClient(); + ConnectionClient(const QString &connectionName); + virtual ~ConnectionClient(); void startProcessAndConnectToServerAsynchronously(); - bool disconnectFromServer(); bool isConnected() const; void sendEndMessage(); @@ -64,18 +65,17 @@ public: void resetProcessAliveTimer(); void setProcessAliveTimerInterval(int processTimerInterval); - const QString &processPath() const; void setProcessPath(const QString &processPath); void restartProcessAsynchronously(); void restartProcessIfTimerIsNotResettedAndSocketIsEmpty(); void finishProcess(); - bool isProcessIsRunning() const; + bool isProcessRunning(); bool waitForEcho(); bool waitForConnected(); - QProcess *processForTestOnly() const; + QProcess *processForTestOnly(); signals: void connectedToLocalSocket(); @@ -90,48 +90,55 @@ protected: virtual void sendEndCommand() = 0; virtual void resetCounter() = 0; - virtual QString connectionName() const = 0; virtual QString outputName() const = 0; + QString connectionName() const; + bool event(QEvent* event); + + virtual void newConnectedServer(QIODevice *ioDevice) = 0; + private: - std::unique_ptr<QProcess> startProcess(); - void finishProcess(std::unique_ptr<QProcess> &&process); - void connectToLocalSocket(); + static bool isProcessRunning(QProcess *process); + void finishProcess(QProcessUniquePointer &&process); void endProcess(QProcess *process); void terminateProcess(QProcess *process); void killProcess(QProcess *process); - void resetProcessIsStarting(); + void finishConnection(); void printLocalSocketError(QLocalSocket::LocalSocketError socketError); void printStandardOutput(); void printStandardError(); + void initializeProcess(QProcess *process); - void resetTemporaryDir(); + void resetTemporaryDirectory(); - void connectLocalSocketConnected(); void connectLocalSocketDisconnected(); - void connectProcessFinished(QProcess *process) const; - void connectProcessStarted(QProcess *process) const; - void disconnectProcessFinished(QProcess *process) const; + void disconnectLocalSocketDisconnected(); void connectStandardOutputAndError(QProcess *process) const; void connectLocalSocketError() const; void connectAliveTimer(); + void connectNewConnection(); + void handleNewConnection(); + void getProcessFromFuture(); + void listenForConnections(); void ensureMessageIsWritten(); QProcessEnvironment processEnvironment() const; +protected: + ProcessCreator m_processCreator; + private: LinePrefixer m_stdErrPrefixer; LinePrefixer m_stdOutPrefixer; - - mutable std::unique_ptr<QProcess> m_process; - QLocalSocket localSocket; - std::unique_ptr<Utils::TemporaryDirectory> m_temporaryDirectory; + QLocalServer m_localServer; + std::future<QProcessUniquePointer> m_processFuture; + mutable QProcessUniquePointer m_process; + QLocalSocket *m_localSocket = nullptr; QTimer m_processAliveTimer; - QString m_processPath; + QString m_connectionName; bool m_isAliveTimerResetted = false; bool m_processIsStarting = false; - }; } // namespace ClangBackEnd |