From efcf6052fef2c07208c75ee0814fa5dabab5600e Mon Sep 17 00:00:00 2001 From: prascle Date: Fri, 2 Dec 2005 13:46:38 +0000 Subject: [PATCH] PR: modifs from Christian Caremoli, embedded interpretor --- src/LightApp/LightApp_Application.cxx | 4 + src/PyInterp/PyInterp_Dispatcher.cxx | 11 +- src/PyInterp/PyInterp_base.cxx | 26 ++- src/PythonConsole/PythonConsole_PyConsole.cxx | 2 + src/PythonConsole/PythonConsole_PyEditor.cxx | 2 + src/PythonConsole/PythonConsole_PyInterp.cxx | 3 + .../SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx | 196 ++++++++++-------- .../SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx | 6 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip | 2 +- src/SalomeApp/SalomeApp_Application.cxx | 9 +- src/SalomeApp/SalomeApp_PyInterp.cxx | 3 + 11 files changed, 165 insertions(+), 99 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index d716f89ea..9f44c9de7 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1281,6 +1281,7 @@ SUIT_Study* LightApp_Application::createNewStudy() /*!Create window.*/ QWidget* LightApp_Application::createWindow( const int flag ) { + cerr << "LightApp_Application::createWindow" << endl; QWidget* wid = 0; if ( flag == WT_ObjectBrowser ) { @@ -1303,9 +1304,11 @@ QWidget* LightApp_Application::createWindow( const int flag ) } else if ( flag == WT_PyConsole ) { + cerr << "LightApp_Application::createWindow: create Python Console" << endl; PythonConsole* pyCons = new PythonConsole( desktop() ); pyCons->setCaption( tr( "PYTHON_CONSOLE" ) ); wid = pyCons; + cerr << "-----------------------------LightApp_Application::createWindow: create Python Console" << endl; // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } else if ( flag == WT_LogWindow ) @@ -1315,6 +1318,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) wid = logWin; logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } + cerr << "------------------------------LightApp_Application::createWindow" << endl; return wid; } diff --git a/src/PyInterp/PyInterp_Dispatcher.cxx b/src/PyInterp/PyInterp_Dispatcher.cxx index 3312e527c..a86e62c1d 100755 --- a/src/PyInterp/PyInterp_Dispatcher.cxx +++ b/src/PyInterp/PyInterp_Dispatcher.cxx @@ -28,12 +28,15 @@ PyInterp_Dispatcher* PyInterp_Dispatcher::myInstance = 0; void PyInterp_Request::process() { + cerr << "PyInterp_Request::process" << endl; safeExecute(); + cerr << "----------PyInterp_Request::process" << endl; myMutex.lock(); if ( !IsSync() && getListener() && getEvent() ) postEvent(); myMutex.unlock(); + cerr << "---------------------------PyInterp_Request::process" << endl; } void PyInterp_Request::safeExecute() @@ -81,10 +84,12 @@ void PyInterp_Request::setListener( QObject* o ) void PyInterp_LockRequest::safeExecute() { + cerr << "PyInterp_Request::safeExecute" << endl; if ( getInterp() ){ PyLockWrapper aLock = getInterp()->GetLockWrapper(); execute(); } + cerr << "---------------------PyInterp_Request::safeExecute" << endl; } ////////////////////////////////////////////////////////// @@ -139,12 +144,15 @@ bool PyInterp_Dispatcher::IsBusy() const void PyInterp_Dispatcher::Exec( PyInterp_Request* theRequest ) { + cerr << "PyInterp_Dispatcher::Exec" << endl; if ( !theRequest ) return; - if ( theRequest->IsSync() && !IsBusy() ) // synchronous processing - nothing is done if dispatcher is busy! + //if ( theRequest->IsSync() && !IsBusy() ) // synchronous processing - nothing is done if dispatcher is busy! + if ( theRequest->IsSync() ) // synchronous processing - nothing is done if dispatcher is busy! processRequest( theRequest ); else { // asynchronous processing + cerr << "PyInterp_Dispatcher::Exec request delayed" << endl; myQueueMutex.lock(); myQueue.push_back( theRequest ); if ( theRequest->getListener() ) @@ -154,6 +162,7 @@ void PyInterp_Dispatcher::Exec( PyInterp_Request* theRequest ) if ( !IsBusy() ) start(); } + cerr << "--------------------------PyInterp_Dispatcher::Exec" << endl; } void PyInterp_Dispatcher::run() diff --git a/src/PyInterp/PyInterp_base.cxx b/src/PyInterp/PyInterp_base.cxx index e9fdcb259..180df0df9 100644 --- a/src/PyInterp/PyInterp_base.cxx +++ b/src/PyInterp/PyInterp_base.cxx @@ -22,15 +22,17 @@ PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): myThreadState(theThreadState), mySaveThreadState(0) { - PyEval_AcquireLock(); - mySaveThreadState = PyThreadState_Swap(myThreadState); // store previous current in save, + PyEval_AcquireThread(myThreadState); + //PyEval_AcquireLock(); + //mySaveThreadState = PyThreadState_Swap(myThreadState); // store previous current in save, // set local in current } PyLockWrapper::~PyLockWrapper(){ - PyThreadState_Swap(mySaveThreadState); // restore previous current (no need to get local, - PyEval_ReleaseLock(); // local thread state* already in _tstate + PyEval_ReleaseThread(myThreadState); + //PyThreadState_Swap(mySaveThreadState); // restore previous current (no need to get local, + //PyEval_ReleaseLock(); // local thread state* already in _tstate } @@ -79,6 +81,7 @@ PyInterp_base::~PyInterp_base() */ void PyInterp_base::initialize() { + cerr << "PyInterp_base::initialize" << endl; _history.clear(); // start a new list of user's commands _ith = _history.begin(); @@ -86,15 +89,19 @@ void PyInterp_base::initialize() // Here the global lock is released // The lock will be acquired in initState. Make provision to release it on exit - PyReleaseLock aReleaseLock; + // PyReleaseLock aReleaseLock; initState(); + + PyLockWrapper aLock= GetLockWrapper(); + initContext(); // used to interpret & compile commands PyObjWrapper m(PyImport_ImportModule("codeop")); if(!m){ PyErr_Print(); + //PyEval_SaveThread(); return; } @@ -106,6 +113,8 @@ void PyInterp_base::initialize() // All the initRun outputs are redirected to the standard output (console) initRun(); + //PyEval_SaveThread(); + cerr << "---------------------------PyInterp_base::initialize" << endl; } void PyInterp_base::init_python() @@ -121,6 +130,7 @@ void PyInterp_base::init_python() PySys_SetArgv(_argc, _argv); PyEval_InitThreads(); // Create (and acquire) the interpreter lock _gtstate = PyEval_SaveThread(); // Release global thread state + // There the thread state is NULL // if(!_gtstate){ // PyReleaseLock aReleaseLock; // Py_Initialize(); // Initialize the interpreter @@ -132,9 +142,11 @@ void PyInterp_base::init_python() string PyInterp_base::getbanner() { + // PyEval_RestoreThread(_tstate); string aBanner("Python "); aBanner = aBanner + Py_GetVersion() + " on " + Py_GetPlatform() ; aBanner = aBanner + "\ntype help to get general information on environment\n"; + //PyEval_SaveThread(); return aBanner; } @@ -228,6 +240,7 @@ int PyInterp_base::run(const char *command) int PyInterp_base::simpleRun(const char *command) { + cerr << "PyInterp_base::simpleRun : " << command << endl; if( !_atFirst && strcmp(command,"") != 0 ) { _history.push_back(command); _ith = _history.end(); @@ -249,6 +262,9 @@ int PyInterp_base::simpleRun(const char *command) // Outputs are redirected on standards outputs (console) PySys_SetObject("stdout",PySys_GetObject("__stdout__")); PySys_SetObject("stderr",PySys_GetObject("__stderr__")); + + cerr << "----------PyInterp_base::simpleRun" << endl; + return ier; } diff --git a/src/PythonConsole/PythonConsole_PyConsole.cxx b/src/PythonConsole/PythonConsole_PyConsole.cxx index 95609f31d..f9ae740d0 100755 --- a/src/PythonConsole/PythonConsole_PyConsole.cxx +++ b/src/PythonConsole/PythonConsole_PyConsole.cxx @@ -12,6 +12,7 @@ using namespace std; PythonConsole::PythonConsole(QWidget* parent, PyInterp_base* interp) : QWidget(parent), myEditor( 0 ) { + cerr << "PythonConsole::PythonConsole" << endl; // create python interpreter myInterp = interp; if ( !myInterp ) @@ -24,6 +25,7 @@ PythonConsole::PythonConsole(QWidget* parent, PyInterp_base* interp) QVBoxLayout* lay = new QVBoxLayout( this ); myEditor = new PythonConsole_PyEditor(myInterp, this,"Python Interpreter"); lay->addWidget( myEditor ); + cerr << "-----------------------------PythonConsole::PythonConsole" << endl; } //**************************************************************** diff --git a/src/PythonConsole/PythonConsole_PyEditor.cxx b/src/PythonConsole/PythonConsole_PyEditor.cxx index 0a5a4f0da..83829d19d 100755 --- a/src/PythonConsole/PythonConsole_PyEditor.cxx +++ b/src/PythonConsole/PythonConsole_PyEditor.cxx @@ -101,6 +101,7 @@ PythonConsole_PyEditor::PythonConsole_PyEditor(PyInterp_base* theInterp, QWidget QTextEdit(theParent,theName), myInterp( 0 ) { + cerr << "PythonConsole_PyEditor::PythonConsole_PyEditor" << endl; QString fntSet( "" ); QFont aFont = SUIT_Tools::stringToFont( fntSet ); setFont(aFont); @@ -114,6 +115,7 @@ PythonConsole_PyEditor::PythonConsole_PyEditor(PyInterp_base* theInterp, QWidget // san - This is necessary for troubleless initialization onPyInterpChanged( theInterp ); + cerr << "------------------------PythonConsole_PyEditor::PythonConsole_PyEditor" << endl; } /*! diff --git a/src/PythonConsole/PythonConsole_PyInterp.cxx b/src/PythonConsole/PythonConsole_PyInterp.cxx index 62b483905..575403926 100755 --- a/src/PythonConsole/PythonConsole_PyInterp.cxx +++ b/src/PythonConsole/PythonConsole_PyInterp.cxx @@ -72,6 +72,7 @@ PythonConsole_PyInterp::~PythonConsole_PyInterp() bool PythonConsole_PyInterp::initState() { + cerr << "PythonConsole_PyInterp::initState" << endl; /* * The GIL is acquired and will be held on initState output * It is the caller responsability to release the lock if needed @@ -92,6 +93,8 @@ bool PythonConsole_PyInterp::initState() _tstate->interp->builtins = PyModule_GetDict(builtinmodule); Py_INCREF(_tstate->interp->builtins); } + PyEval_ReleaseThread(_tstate); + cerr << "--------------------------PythonConsole_PyInterp::initState" << endl; return true; } diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx index f0dbdab60..600699ea8 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx @@ -450,6 +450,7 @@ void SALOME_PYQT_Module::viewManagers( QStringList& listik ) const */ void SALOME_PYQT_Module::init( CAM_Application* app ) { + cerr << "SALOME_PYQT_Module::init" << endl; // reset interpreter to NULL myInterp = NULL; @@ -485,11 +486,13 @@ void SALOME_PYQT_Module::init( CAM_Application* app ) PyLockWrapper aLock = myInterp->GetLockWrapper(); // ... (the Python module is already imported) // ... finally call Python module's initialize() method - PyObjWrapper res( PyObject_CallMethod( myModule, "initialize", "" ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "initialize")){ + PyObjWrapper res( PyObject_CallMethod( myModule, "initialize", "" ) ); + if( !res ) { + // CCAR already tested // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } } // get the windows list from the Python module by calling windows() method @@ -499,55 +502,60 @@ void SALOME_PYQT_Module::init( CAM_Application* app ) // VSR: LogWindow is not yet implemented // myWindowsMap.insert( SalomeApp_Application::WT_LogWindow, Qt::DockBottom ); - PyObjWrapper res1( PyObject_CallMethod( myModule, "windows", "" ) ); - if( !res1 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); - } - else { - myWindowsMap.clear(); - if ( PyDict_Check( res1 ) ) { - PyObject* key; - PyObject* value; - int pos = 0; - while ( PyDict_Next( res1, &pos, &key, &value ) ) { - // parse the return value - // it should be a map: {integer:integer} - int aKey, aValue; - if( key && PyInt_Check( key ) && value && PyInt_Check( value ) ) { - aKey = PyInt_AsLong( key ); - aValue = PyInt_AsLong( value ); - myWindowsMap[ aKey ] = aValue; - } + if(PyObject_HasAttrString(myModule , "windows")){ + PyObjWrapper res1( PyObject_CallMethod( myModule, "windows", "" ) ); + if( !res1 ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } + else { + myWindowsMap.clear(); + if ( PyDict_Check( res1 ) ) { + PyObject* key; + PyObject* value; + int pos = 0; + while ( PyDict_Next( res1, &pos, &key, &value ) ) { + // parse the return value + // it should be a map: {integer:integer} + int aKey, aValue; + if( key && PyInt_Check( key ) && value && PyInt_Check( value ) ) { + aKey = PyInt_AsLong( key ); + aValue = PyInt_AsLong( value ); + myWindowsMap[ aKey ] = aValue; + } + } } } } // get the windows list from the Python module by calling views() method - PyObjWrapper res2( PyObject_CallMethod( myModule, "views", "" ) ); - if( !res2 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); - } - else { - // parse the return value - // result can be one string... - if ( PyString_Check( res2 ) ) { - myViewMgrList.append( PyString_AsString( res2 ) ); + if(PyObject_HasAttrString(myModule , "views")){ + PyObjWrapper res2( PyObject_CallMethod( myModule, "views", "" ) ); + if( !res2 ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); } - // ... or list of strings - else if ( PyList_Check( res2 ) ) { - int size = PyList_Size( res2 ); - for ( int i = 0; i < size; i++ ) { - PyObject* value = PyList_GetItem( res2, i ); - if( value && PyString_Check( value ) ) { - myViewMgrList.append( PyString_AsString( value ) ); - } + else { + // parse the return value + // result can be one string... + if ( PyString_Check( res2 ) ) { + myViewMgrList.append( PyString_AsString( res2 ) ); + } + // ... or list of strings + else if ( PyList_Check( res2 ) ) { + int size = PyList_Size( res2 ); + for ( int i = 0; i < size; i++ ) { + PyObject* value = PyList_GetItem( res2, i ); + if( value && PyString_Check( value ) ) { + myViewMgrList.append( PyString_AsString( value ) ); + } + } } } } myInitModule = 0; + cerr << "----------------------SALOME_PYQT_Module::init" << endl; } /*! @@ -578,20 +586,24 @@ void SALOME_PYQT_Module::activate( SUIT_Study* theStudy ) if ( IsCallOldMethods ) { //__CALL_OLD_METHODS__ // call Python module's setSettings() method (obsolete) - PyObjWrapper res( PyObject_CallMethod( myModule, "setSettings", "" ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "setSettings")){ + PyObjWrapper res( PyObject_CallMethod( myModule, "setSettings", "" ) ); + if( !res ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } } } //__CALL_OLD_METHODS__ // call Python module's activate() method (for the new modules) - PyObjWrapper res1( PyObject_CallMethod( myModule, "activate", "" ) ); - if( !res1 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "activate")){ + PyObjWrapper res1( PyObject_CallMethod( myModule, "activate", "" ) ); + if( !res1 ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } } } @@ -607,11 +619,13 @@ void SALOME_PYQT_Module::deactivate( SUIT_Study* theStudy ) return; } // then call Python module's deactivate() method - PyObjWrapper res( PyObject_CallMethod( myModule, "deactivate", "" ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "deactivate")){ + PyObjWrapper res( PyObject_CallMethod( myModule, "deactivate", "" ) ); + if( !res ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } } } @@ -641,11 +655,13 @@ void SALOME_PYQT_Module::studyChanged( SUIT_Study* theStudy ) PyLockWrapper aLock = myInterp->GetLockWrapper(); // call Python module's activeStudyChanged() method - PyObjWrapper res( PyObject_CallMethod( myModule, "activeStudyChanged", "i", aStudyId ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "activeStudyChanged")){ + PyObjWrapper res( PyObject_CallMethod( myModule, "activeStudyChanged", "i", aStudyId ) ); + if( !res ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } } } @@ -723,8 +739,8 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the return; QString aContext( theContext ), aObject( "" ), aParent( "" ); - - if ( IsCallOldMethods ) { //__CALL_OLD_METHODS__ + + if ( IsCallOldMethods && PyObject_HasAttrString(myModule , "definePopup") ) { //__CALL_OLD_METHODS__ // call definePopup() Python module's function // this is obsolete function, used only for compatibility reasons PyObjWrapper res(PyObject_CallMethod( myModule, @@ -735,8 +751,8 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the aParent.latin1() ) ); if( !res ) { // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + PyErr_Print(); + //PyErr_Clear(); } else { // parse return value @@ -757,18 +773,20 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the PyObjWrapper sipPopup( sipBuildResult( 0, "M", thePopupMenu, sipClass_QPopupMenu ) ); // then call Python module's createPopupMenu() method (for new modules) - PyObjWrapper res1( PyObject_CallMethod( myModule, + if ( PyObject_HasAttrString(myModule , "createPopupMenu") ) { + PyObjWrapper res1( PyObject_CallMethod( myModule, "createPopupMenu", "Os", sipPopup.get(), aContext.latin1() ) ); - if( !res1 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if( !res1 ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } } - if ( IsCallOldMethods ) { //__CALL_OLD_METHODS__ + if ( IsCallOldMethods && PyObject_HasAttrString(myModule , "customPopup") ) { //__CALL_OLD_METHODS__ // call customPopup() Python module's function // this is obsolete function, used only for compatibility reasons PyObjWrapper res2( PyObject_CallMethod( myModule, @@ -780,8 +798,8 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the aParent.latin1() ) ); if( !res2 ) { // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + PyErr_Print(); + //PyErr_Clear(); } } //__CALL_OLD_METHODS__ } @@ -797,11 +815,13 @@ void SALOME_PYQT_Module::guiEvent( const int theId ) if ( !myInterp || !myModule ) return; - PyObjWrapper res( PyObject_CallMethod( myModule, "OnGUIEvent", "i", theId ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if ( PyObject_HasAttrString(myModule , "OnGUIEvent") ) { + PyObjWrapper res( PyObject_CallMethod( myModule, "OnGUIEvent", "i", theId ) ); + if( !res ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } } } @@ -916,11 +936,13 @@ void SALOME_PYQT_Module::setWorkSpace() } PyObjWrapper pyws( sipBuildResult( 0, "M", aWorkspace, sipClass_QWidget ) ); // ... and finally call Python module's setWorkspace() method (obsolete) - PyObjWrapper res( PyObject_CallMethod( myModule, "setWorkSpace", "O", pyws.get() ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if ( PyObject_HasAttrString(myModule , "setWorkSpace") ) { + PyObjWrapper res( PyObject_CallMethod( myModule, "setWorkSpace", "O", pyws.get() ) ); + if( !res ) { + // VSR: this method may not be implemented in Python module + PyErr_Print(); + //PyErr_Clear(); + } } } //__CALL_OLD_METHODS__ } diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx index 12ede8810..61a323dc8 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx @@ -38,9 +38,11 @@ bool SALOME_PYQT_PyInterp::initState() */ SCRUTE(KERNEL_PYTHON::_gtstate); _tstate = KERNEL_PYTHON::_gtstate; - PyEval_AcquireLock(); - PyThreadState_Swap(_tstate); + //PyEval_AcquireLock(); + //PyThreadState_Swap(_tstate); + PyEval_AcquireThread(_tstate); SCRUTE(_tstate); + PyEval_ReleaseThread(_tstate); return true; } diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip index eee54b26c..f306399b1 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip @@ -73,7 +73,7 @@ public: static const QString getActiveComponent(); static void updateObjBrowser( const int = 0, bool = true ); - static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool ); + static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ; static QStringList getOpenFileNames ( QWidget*, const QString&, const QStringList&, const QString& ); static QString getExistingDirectory( QWidget*, const QString&, const QString& ); diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 26df49c6c..c804b6a63 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -548,7 +548,9 @@ QString SalomeApp_Application::getFileFilter() const /*!Create window.*/ QWidget* SalomeApp_Application::createWindow( const int flag ) { - QWidget* wid = LightApp_Application::createWindow(flag); + cerr << "SalomeApp_Application::createWindow" << endl; + QWidget* wid = 0; + if ( flag != WT_PyConsole ) wid = LightApp_Application::createWindow(flag); SUIT_ResourceMgr* resMgr = resourceMgr(); @@ -567,13 +569,14 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) } else if ( flag == WT_PyConsole ) { - delete wid; - wid = 0; + cerr << "create Python Console" << endl; PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() ); pyCons->setCaption( tr( "PYTHON_CONSOLE" ) ); wid = pyCons; + cerr << "-------------------create Python Console" << endl; // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } + cerr << "----------------------------------SalomeApp_Application::createWindow" << endl; return wid; } diff --git a/src/SalomeApp/SalomeApp_PyInterp.cxx b/src/SalomeApp/SalomeApp_PyInterp.cxx index a6549f646..d702d1a59 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.cxx +++ b/src/SalomeApp/SalomeApp_PyInterp.cxx @@ -37,6 +37,7 @@ #include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)! #include +using namespace std; /*! * constructor : multi Python interpreter, one per SALOME study. @@ -80,6 +81,7 @@ bool SalomeApp_PyInterp::initContext() * It is the caller responsability caller to acquire the GIL * It will still be held on initContext output */ + cerr << "SalomeApp_PyInterp::initContext" << endl; if ( !PythonConsole_PyInterp::initContext() ) return false; @@ -107,6 +109,7 @@ bool SalomeApp_PyInterp::initContext() return false; } + cerr << "------------------SalomeApp_PyInterp::initContext" << endl; return true; } -- 2.39.2