]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #79: Pass events from python thread to Qt's thread
authorsbh <sergey.belash@opencascade.com>
Mon, 15 Sep 2014 09:12:09 +0000 (13:12 +0400)
committersbh <sergey.belash@opencascade.com>
Mon, 15 Sep 2014 09:12:09 +0000 (13:12 +0400)
src/XGUI/XGUI_QtEvents.cpp
src/XGUI/XGUI_QtEvents.h
src/XGUI/XGUI_Workshop.cpp

index e3eb2b0919c6027c41046e54d43181f22259e834..a8e6201781f11e64f74b68f46ca90b39c7c74396 100644 (file)
 QEvent::Type PostponeMessageQtEvent::PostponeMessageQtEventType = QEvent::Type(QEvent::registerEventType());
 
 
-//TODO(mpv): #4
-//boost::shared_ptr<Events_Message> PostponeMessageQtEvent::postponedMessage()
-boost::shared_ptr<ModelAPI_Document> PostponeMessageQtEvent::resultDoc()
+boost::shared_ptr<Events_Message> PostponeMessageQtEvent::postponedMessage()
 {
-  return myTestDoc;
+  return myMessage;
 }
 
index 5c415a278fcaeaeca10a4edeb536721e629e8325..4fdb3385744e7c20eb504db6ffc7f5acd3d3213e 100644 (file)
@@ -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<ModelAPI_Document> theDoc)
-  //PostponeMessageQtEvent(boost::shared_ptr<Events_Message> theMessage)
+  PostponeMessageQtEvent(const boost::shared_ptr<Events_Message>& 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<Events_Message> postponedMessage();
-  boost::shared_ptr<ModelAPI_Document> resultDoc();
+  boost::shared_ptr<Events_Message> postponedMessage();
 
  private:
-  //TODO(mpv): #3
-  //boost::shared_ptr<Events_Message> myMessage;
-  boost::shared_ptr<ModelAPI_Document> myTestDoc;
+  boost::shared_ptr<Events_Message> myMessage;
 };
 
 #endif /* XGUI_QEVENTS_H_ */
index a3fac8efc54a4c71c8aefc520bfe60b3d418b259..d337c1856bd52587277f2ec8f48bbc4e84a4340c 100644 (file)
@@ -240,7 +240,7 @@ void XGUI_Workshop::processEvent(const boost::shared_ptr<Events_Message>& 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<ModelAPI_Document> 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<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
-    //processEvent(aEventPtr);
+    boost::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
+    processEvent(aEventPtr);
     return true;
   }
   return false;