From fee992951cff20d5a8e04c44f651f4eedfa9b2c8 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 30 Jun 2008 11:30:21 +0000 Subject: [PATCH] Fix problem with executing of GUI-related command from the embeded Python interpreter: crash with Qt's message "cannot send event to the object created in another thread" --- src/Makefile.am | 4 ++-- src/PyInterp/Makefile.am | 5 +++-- src/PyInterp/PyInterp_Dispatcher.cxx | 17 +++++++++++++++-- src/PyInterp/PyInterp_Dispatcher.h | 2 ++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 91f5dce0a..82c27dbce 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,7 @@ # Module : SALOME # $Header$ -SUBDIRS = CASCatch Qtx Style DDS QDS ObjBrowser SUIT SUITApp STD CAF CAM LogWindow Prs +SUBDIRS = CASCatch Qtx Style DDS QDS ObjBrowser SUIT SUITApp STD CAF CAM LogWindow Prs Event if ENABLE_SALOMEOBJECT SUBDIRS += OBJECT @@ -61,7 +61,7 @@ endif if ENABLE_QXGRAPHVIEWER SUBDIRS += QxGraph endif -SUBDIRS += Event LightApp ResExporter +SUBDIRS += LightApp ResExporter if GUI_ENABLE_CORBA SUBDIRS += TOOLSGUI Session SalomeApp SALOME_SWIG SALOME_PY SALOME_PYQT diff --git a/src/PyInterp/Makefile.am b/src/PyInterp/Makefile.am index 7a451b4ad..c601b310d 100755 --- a/src/PyInterp/Makefile.am +++ b/src/PyInterp/Makefile.am @@ -39,5 +39,6 @@ dist_libPyInterp_la_SOURCES= \ MOC_FILES= PyInterp_Watcher_moc.cxx nodist_libPyInterp_la_SOURCES= $(MOC_FILES) -libPyInterp_la_CPPFLAGS= $(PYTHON_INCLUDES) $(QT_INCLUDES) -libPyInterp_la_LDFLAGS= $(PYTHON_LIBS) $(QT_MT_LIBS) +libPyInterp_la_CPPFLAGS= $(PYTHON_INCLUDES) $(QT_INCLUDES) \ + -I$(srcdir)/../Event +libPyInterp_la_LDFLAGS= $(PYTHON_LIBS) $(QT_MT_LIBS) ../Event/libEvent.la diff --git a/src/PyInterp/PyInterp_Dispatcher.cxx b/src/PyInterp/PyInterp_Dispatcher.cxx index 052ccbf19..2fbda19ee 100755 --- a/src/PyInterp/PyInterp_Dispatcher.cxx +++ b/src/PyInterp/PyInterp_Dispatcher.cxx @@ -23,10 +23,23 @@ #include "PyInterp_Dispatcher.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!! #include "PyInterp_Interp.h" #include "PyInterp_Watcher.h" +#include #include #include +class PyInterp_ExecuteEvent: public SALOME_Event +{ +public: + PyInterp_Request* myRequest; + PyInterp_ExecuteEvent( PyInterp_Request* r ) + : myRequest( r ) {} + virtual void Execute() + { + myRequest->execute(); + } +}; + using namespace std; PyInterp_Dispatcher* PyInterp_Dispatcher::myInstance = 0; @@ -49,7 +62,7 @@ void PyInterp_Request::process() void PyInterp_Request::safeExecute() { - execute(); + ProcessVoidEvent( new PyInterp_ExecuteEvent( this ) ); } void PyInterp_Request::Destroy( PyInterp_Request* request ) @@ -94,7 +107,7 @@ void PyInterp_LockRequest::safeExecute() { if ( getInterp() ){ PyLockWrapper aLock = getInterp()->GetLockWrapper(); - execute(); + ProcessVoidEvent( new PyInterp_ExecuteEvent( this ) ); } } diff --git a/src/PyInterp/PyInterp_Dispatcher.h b/src/PyInterp/PyInterp_Dispatcher.h index 903fea356..5040b1032 100755 --- a/src/PyInterp/PyInterp_Dispatcher.h +++ b/src/PyInterp/PyInterp_Dispatcher.h @@ -35,10 +35,12 @@ class QObject; class PyInterp_Interp; class PyInterp_Watcher; class PyInterp_Dispatcher; +class PyInterp_ExecuteEvent; class PYINTERP_EXPORT PyInterp_Request { friend class PyInterp_Dispatcher; + friend class PyInterp_ExecuteEvent; PyInterp_Request(); PyInterp_Request( const PyInterp_Request& ); -- 2.39.2