From 34c6e6408c3ce930d08ae1058efaef19eaa2a2e6 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Fri, 7 Sep 2012 15:06:05 +0200 Subject: [PATCH] scide: SCProcess - try to prevent multiple connections Signed-off-by: Tim Blechmann --- editors/sc-ide/core/sc_process.cpp | 19 +++++++++++++++++++ editors/sc-ide/core/sc_process.hpp | 17 ++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/editors/sc-ide/core/sc_process.cpp b/editors/sc-ide/core/sc_process.cpp index 0f5055fda..242a1a105 100644 --- a/editors/sc-ide/core/sc_process.cpp +++ b/editors/sc-ide/core/sc_process.cpp @@ -37,6 +37,7 @@ namespace ScIDE { SCProcess::SCProcess( Main *parent, ScResponder * responder, Settings::Manager * settings ): QProcess( parent ), mIpcServer( new QLocalServer(this) ), + mIpcSocket(NULL), mIpcServerName("SCIde_" + QString::number(QCoreApplication::applicationPid())) { mIntrospectionParser = new ScIntrospectionParser( responder, this ); @@ -192,6 +193,24 @@ void SCProcess::evaluateCode(QString const & commandString, bool silent) write( &commandChar, 1 ); } +void SCProcess::onNewIpcConnection() +{ + if (mIpcSocket) + // we can handle only one ipc connection at a time + mIpcSocket->disconnect(); + + mIpcSocket = mIpcServer->nextPendingConnection(); + connect(mIpcSocket, SIGNAL(disconnected()), this, SLOT(finalizeConnection())); + connect(mIpcSocket, SIGNAL(readyRead()), this, SLOT(onIpcData())); +} + +void SCProcess::finalizeConnection() +{ + mIpcData.clear(); + mIpcSocket->deleteLater(); + mIpcSocket = NULL; +} + void SCProcess::onIpcData() { mIpcData.append(mIpcSocket->readAll()); diff --git a/editors/sc-ide/core/sc_process.hpp b/editors/sc-ide/core/sc_process.hpp index 48ef94ead..f0fe98e16 100644 --- a/editors/sc-ide/core/sc_process.hpp +++ b/editors/sc-ide/core/sc_process.hpp @@ -25,13 +25,13 @@ #include "settings/manager.hpp" #include +#include +#include #include +#include +#include #include #include -#include -#include -#include -#include namespace ScIDE { @@ -98,14 +98,9 @@ public slots: } private slots: - void onNewIpcConnection() - { - mIpcSocket = mIpcServer->nextPendingConnection(); - connect(mIpcSocket, SIGNAL(disconnected()), mIpcSocket, SLOT(deleteLater())); - connect(mIpcSocket, SIGNAL(readyRead()), this, SLOT(onIpcData())); - } - + void onNewIpcConnection(); void onIpcData(); + void finalizeConnection(); private: void onSclangStart(); -- 2.11.4.GIT