From ecc81e20f06b12daa86637ac793cc1aaaef3d13c Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Tue, 11 Sep 2012 11:25:52 +0200 Subject: [PATCH] scide: cancel ScRequests when recompiling the class library Signed-off-by: Tim Blechmann --- SCClassLibrary/scide_scqt/ScIDE.sc | 75 +++++++++++++------------ editors/sc-ide/core/sc_process.cpp | 5 +- editors/sc-ide/core/sc_process.hpp | 20 ++++++- editors/sc-ide/widgets/sc_symbol_references.cpp | 6 ++ editors/sc-ide/widgets/sc_symbol_references.hpp | 1 + 5 files changed, 67 insertions(+), 40 deletions(-) diff --git a/SCClassLibrary/scide_scqt/ScIDE.sc b/SCClassLibrary/scide_scqt/ScIDE.sc index ee6baf6cc..6bb101202 100644 --- a/SCClassLibrary/scide_scqt/ScIDE.sc +++ b/SCClassLibrary/scide_scqt/ScIDE.sc @@ -10,22 +10,23 @@ ScIDE { StartUp.add { if (ScIDE.connected) { - this.handshake + this.handshake }; } } *connect {|ideName| this.prConnect(ideName); - defer { - this.handshake - } + defer { + this.handshake + } } - *handshake { - this.prSend(\requestCurrentPath); + *handshake { + this.prSend(\classLibraryRecompiled); + this.prSend(\requestCurrentPath); - defaultServer = Server.default; + defaultServer = Server.default; SimpleController(defaultServer) .put(\serverRunning, { | server, what, extraArg | @@ -33,10 +34,10 @@ ScIDE { this.prSend(\defaultServerRunningChanged, [server.serverRunning, addr.hostname, addr.port]) }); - this.prSend(\defaultServerRunningChanged, [defaultServer.serverRunning, defaultServer.addr.hostname, defaultServer.addr.port]); + this.prSend(\defaultServerRunningChanged, [defaultServer.serverRunning, defaultServer.addr.hostname, defaultServer.addr.port]); - this.sendIntrospection; // sending the introspection at the end, as otherwise the communication channel seems to get stuck - } + this.sendIntrospection; // sending the introspection at the end, as otherwise the communication channel seems to get stuck + } *request { |id, command, data| this.tryPerform(command, id, data); @@ -118,7 +119,7 @@ ScIDE { // methods include operators like "+", but those are // actually not valid in the method call syntax if (method.name.asString[0].isAlpha && - methods[method.name].isNil) + methods[method.name].isNil) { methods.put(method.name, method); }; @@ -228,32 +229,32 @@ ScIDE { }; } - *findReferencesToSymbol {|requestId, symbol| - var methods; - var result = SortedList(8, subListSorter); - var references = Class.findAllReferences(symbol.asSymbol); - - if (references.notNil) { - methods = IdentitySet.new; - references.do { | funcDef | - var homeContext; - homeContext = if(funcDef.context.isNil) {funcDef} {funcDef.context.homeContext}; - if (homeContext.isKindOf(Method)) { - methods.add(homeContext); - }; - }; - methods.do { | method | - result.add([ - method.ownerClass.name, - method.name, - method.filenameSymbol.asString, - method.charPos + 1 - ]) - } - }; - - ScIDE.prSend(requestId, [symbol, result.asArray]) - } + *findReferencesToSymbol {|requestId, symbol| + var methods; + var result = SortedList(8, subListSorter); + var references = Class.findAllReferences(symbol.asSymbol); + + if (references.notNil) { + methods = IdentitySet.new; + references.do { | funcDef | + var homeContext; + homeContext = if(funcDef.context.isNil) {funcDef} {funcDef.context.homeContext}; + if (homeContext.isKindOf(Method)) { + methods.add(homeContext); + }; + }; + methods.do { | method | + result.add([ + method.ownerClass.name, + method.name, + method.filenameSymbol.asString, + method.charPos + 1 + ]) + } + }; + + ScIDE.prSend(requestId, [symbol, result.asArray]) + } *prSend {|id, data| _ScIDE_Send diff --git a/editors/sc-ide/core/sc_process.cpp b/editors/sc-ide/core/sc_process.cpp index b3a961f0c..542497d1b 100644 --- a/editors/sc-ide/core/sc_process.cpp +++ b/editors/sc-ide/core/sc_process.cpp @@ -271,6 +271,7 @@ void ScResponder::onResponse( const QString & selector, const QString & data ) static QString introspectionSymbol("introspection"); static QString requestCurrentPathSymbol("requestCurrentPath"); static QString openFileSymbol("openFile"); + static QString classLibraryRecompiled("classLibraryRecompiled"); if (selector == defaultServerRunningChangedSymbol) handleServerRunningChanged(data); @@ -281,12 +282,14 @@ void ScResponder::onResponse( const QString & selector, const QString & data ) else if (selector == requestCurrentPathSymbol) Main::scProcess()->sendActiveDocument(); + else if (selector == classLibraryRecompiled) + Main::scProcess()->emitClassLibraryRecompiled(); + else if (selector == openFileSymbol) handleOpenFile(data); } - void ScResponder::handleOpenFile( const QString & data ) const { std::stringstream stream; diff --git a/editors/sc-ide/core/sc_process.hpp b/editors/sc-ide/core/sc_process.hpp index d3e293f38..34a710921 100644 --- a/editors/sc-ide/core/sc_process.hpp +++ b/editors/sc-ide/core/sc_process.hpp @@ -77,10 +77,16 @@ public: return mActions[role]; } + void emitClassLibraryRecompiled() + { + emit classLibraryRecompiled(); + } + Q_SIGNALS: void scPost(QString const &); void statusMessage(const QString &); void response(const QString & id, const QString & data); + void classLibraryRecompiled(); public slots: void recompileClassLibrary (void); @@ -132,6 +138,9 @@ public: { connect(mSc, SIGNAL(response(QString,QString)), this, SLOT(onResponse(QString,QString))); + + connect(mSc, SIGNAL(classLibraryRecompiled()), + this, SLOT(onCancelRequest())); } void send( const QString & command, const QString & data ) @@ -148,13 +157,20 @@ public: signals: void response( const QString & command, const QString & data ); + void requestCanceled(); private slots: + void onCancelRequest() + { + cancel(); + emit requestCanceled(); + deleteLater(); + } + void onResponse( const QString & responseId, const QString & responseData ) { - if (responseId == mId.toString()) { + if (responseId == mId.toString()) emit response(mCommand, responseData); - } } private: diff --git a/editors/sc-ide/widgets/sc_symbol_references.cpp b/editors/sc-ide/widgets/sc_symbol_references.cpp index e76f4984c..8264adf71 100644 --- a/editors/sc-ide/widgets/sc_symbol_references.cpp +++ b/editors/sc-ide/widgets/sc_symbol_references.cpp @@ -49,9 +49,15 @@ void ReferencesDialog::performQuery() SymbolReferenceRequest * request = new SymbolReferenceRequest(Main::scProcess(), this); connect(request, SIGNAL(response(QString,QString)), this, SLOT(onResposeFromLanguage(QString,QString))); + connect(request, SIGNAL(requestCanceled()), this, SLOT(requestCanceled())); request->sendRequest(queryString); } +void ReferencesDialog::requestCanceled() +{ + mResult->setModel(NULL); +} + void ReferencesDialog::onResposeFromLanguage(const QString &, const QString &responseData) { QStandardItemModel * model = parse(responseData); diff --git a/editors/sc-ide/widgets/sc_symbol_references.hpp b/editors/sc-ide/widgets/sc_symbol_references.hpp index 3ed42ddc5..f88d50300 100644 --- a/editors/sc-ide/widgets/sc_symbol_references.hpp +++ b/editors/sc-ide/widgets/sc_symbol_references.hpp @@ -56,6 +56,7 @@ public: explicit ReferencesDialog(QWidget * parent = NULL); private slots: + void requestCanceled(); void performQuery(); void onResposeFromLanguage(const QString &command, const QString &responseData); QStandardItemModel * parse(QString const & responseData); -- 2.11.4.GIT