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>
This commit is contained in:
Marco Bubke
2016-08-17 15:29:37 +02:00
parent 45c667d52c
commit f70bf3d2d1
44 changed files with 1170 additions and 351 deletions

View File

@@ -25,6 +25,8 @@
#include "refactoringconnectionclient.h"
#include <utils/temporarydirectory.h>
#include <QCoreApplication>
namespace ClangBackEnd {
@@ -39,8 +41,13 @@ QString currentProcessId()
}
RefactoringConnectionClient::RefactoringConnectionClient(RefactoringClientInterface *client)
: serverProxy_(client, ioDevice())
: ConnectionClient(Utils::TemporaryDirectory::masterDirectoryPath()
+ QStringLiteral("/ClangRefactoringBackEnd-")
+ currentProcessId()),
m_serverProxy(client, nullptr)
{
m_processCreator.setTemporaryDirectoryPattern("clangrefactoringbackend-XXXXXX");
stdErrPrefixer().setPrefix("RefactoringConnectionClient.stderr: ");
stdOutPrefixer().setPrefix("RefactoringConnectionClient.stdout: ");
}
@@ -52,22 +59,17 @@ RefactoringConnectionClient::~RefactoringConnectionClient()
RefactoringServerProxy &RefactoringConnectionClient::serverProxy()
{
return serverProxy_;
return m_serverProxy;
}
void RefactoringConnectionClient::sendEndCommand()
{
serverProxy_.end();
m_serverProxy.end();
}
void RefactoringConnectionClient::resetCounter()
{
serverProxy_.resetCounter();
}
QString RefactoringConnectionClient::connectionName() const
{
return temporaryDirectory().path() + QStringLiteral("/ClangRefactoringBackEnd-") + currentProcessId();
m_serverProxy.resetCounter();
}
QString RefactoringConnectionClient::outputName() const
@@ -75,4 +77,9 @@ QString RefactoringConnectionClient::outputName() const
return QStringLiteral("RefactoringConnectionClient");
}
void RefactoringConnectionClient::newConnectedServer(QIODevice *ioDevice)
{
m_serverProxy.setIoDevice(ioDevice);
}
} // namespace ClangBackEnd

View File

@@ -43,11 +43,11 @@ public:
protected:
void sendEndCommand() override;
void resetCounter() override;
QString connectionName() const override;
QString outputName() const override;
void newConnectedServer(QIODevice *ioDevice) override;
private:
RefactoringServerProxy serverProxy_;
RefactoringServerProxy m_serverProxy;
};
} // namespace ClangBackEnd

View File

@@ -41,8 +41,8 @@ namespace ClangRefactoring {
class RefactoringEngine : public CppTools::RefactoringEngineInterface
{
public:
RefactoringEngine(ClangBackEnd::RefactoringServerInterface &m_server,
ClangBackEnd::RefactoringClientInterface &m_client,
RefactoringEngine(ClangBackEnd::RefactoringServerInterface &server,
ClangBackEnd::RefactoringClientInterface &client,
ClangBackEnd::FilePathCachingInterface &filePathCache,
SymbolQueryInterface &symbolQuery);
~RefactoringEngine() override;