From e2cdef6eb034a1b8c9ffea3fd43ad69a39dd5b9a Mon Sep 17 00:00:00 2001 From: sbh Date: Mon, 15 Sep 2014 13:12:09 +0400 Subject: [PATCH] Issue #79: Pass events from python thread to Qt's thread --- src/XGUI/XGUI_QtEvents.cpp | 6 ++---- src/XGUI/XGUI_QtEvents.h | 18 ++++-------------- src/XGUI/XGUI_Workshop.cpp | 14 +++----------- 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/XGUI/XGUI_QtEvents.cpp b/src/XGUI/XGUI_QtEvents.cpp index e3eb2b091..a8e620178 100644 --- a/src/XGUI/XGUI_QtEvents.cpp +++ b/src/XGUI/XGUI_QtEvents.cpp @@ -10,10 +10,8 @@ QEvent::Type PostponeMessageQtEvent::PostponeMessageQtEventType = QEvent::Type(QEvent::registerEventType()); -//TODO(mpv): #4 -//boost::shared_ptr PostponeMessageQtEvent::postponedMessage() -boost::shared_ptr PostponeMessageQtEvent::resultDoc() +boost::shared_ptr PostponeMessageQtEvent::postponedMessage() { - return myTestDoc; + return myMessage; } diff --git a/src/XGUI/XGUI_QtEvents.h b/src/XGUI/XGUI_QtEvents.h index 5c415a278..4fdb33857 100644 --- a/src/XGUI/XGUI_QtEvents.h +++ b/src/XGUI/XGUI_QtEvents.h @@ -21,15 +21,9 @@ class XGUI_EXPORT PostponeMessageQtEvent : public QEvent public: static QEvent::Type PostponeMessageQtEventType; - //TODO(mpv): ModelAPI_Document is taken here for example - //the commented code should be ok when you implement boost::shared_ptr on Events_Message - //the same for #1-4 - PostponeMessageQtEvent(boost::shared_ptr theDoc) - //PostponeMessageQtEvent(boost::shared_ptr theMessage) + PostponeMessageQtEvent(const boost::shared_ptr& theMessage) : QEvent(PostponeMessageQtEventType), - //TODO(mpv): #1 - //myMessage(theMessage) - myTestDoc(theDoc) + myMessage(theMessage) { } static QEvent::Type type() @@ -37,14 +31,10 @@ class XGUI_EXPORT PostponeMessageQtEvent : public QEvent return PostponeMessageQtEventType; } - //TODO(mpv): #2 - //boost::shared_ptr postponedMessage(); - boost::shared_ptr resultDoc(); + boost::shared_ptr postponedMessage(); private: - //TODO(mpv): #3 - //boost::shared_ptr myMessage; - boost::shared_ptr myTestDoc; + boost::shared_ptr myMessage; }; #endif /* XGUI_QEVENTS_H_ */ diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index a3fac8efc..d337c1856 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -240,7 +240,7 @@ void XGUI_Workshop::processEvent(const boost::shared_ptr& theMes std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl; #endif SessionPtr aMgr = ModelAPI_Session::get(); - PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(aMgr->activeDocument()); + PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage); QApplication::postEvent(this, aPostponeEvent); return; } @@ -499,16 +499,8 @@ bool XGUI_Workshop::event(QEvent * theEvent) std::cout << "XGUI_Workshop::event " << "I am in the Qt's thread: " << isMyThread << std::endl; #endif - boost::shared_ptr aDoc = aPostponedEv->resultDoc(); - if (aDoc) { -#ifdef _DEBUG - std::cout << "XGUI_Workshop::event " << "Passed boost ptr is ok, doc id: " << aDoc->id() - << std::endl; -#endif - } - //TODO(mpv): After modifications in the XGUI_QtEvents.* this code should be like... - //boost::shared_ptr aEventPtr = aPostponedEv->postponedMessage(); - //processEvent(aEventPtr); + boost::shared_ptr aEventPtr = aPostponedEv->postponedMessage(); + processEvent(aEventPtr); return true; } return false; -- 2.39.2