From 5265189d48cb9000bb9d19626be9f30f96608a96 Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 14 Apr 2004 07:52:53 +0000 Subject: [PATCH] PR: bug 5694 correction --- src/SALOME_PYQT/SALOME_PYQT_GUI.cxx | 31 ++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx index dc3ff8b41..e9e13645b 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx @@ -43,15 +43,26 @@ static void setWorkSpace() { MESSAGE("setWorkSpace"); PyObject *res,*pyws; + PyObject *qtmodule; interp->enter(); + // Try to import qt module. If it's not possible don't go on + qtmodule=PyImport_ImportModule("qt"); + if (qtmodule == NULL) + { + MESSAGE ( " Problem... " ); + PyErr_Print(); + interp->quit(); + return ; + } + // Now it's safe to map, through sip, C++ pointer to Python object pyws=sipMapCppToSelf( QAD_Application::getDesktop()->getMainFrame(), sipClass_QWorkspace); res=PyObject_CallMethod(module,"setWorkSpace","O",pyws); - SCRUTE(pyws->ob_refcnt); Py_DECREF(pyws); if (res == NULL) { + MESSAGE ( " Problem... " ); PyErr_Print(); interp->quit(); return ; @@ -163,8 +174,8 @@ bool SALOME_PYQT_GUI::OnMouseMove (QMouseEvent* pe , QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - // La ligne suivante est commentée sinon multiple traces ... - // MESSAGE("SALOME_PYQT_GUI::OnMouseMouve"); + // Commented out to avoid multiple traces ... + // MESSAGE("SALOME_PYQT_GUI::OnMouseMove"); return true; } @@ -186,6 +197,20 @@ bool SALOME_PYQT_GUI::SetSettings (QAD_Desktop* parent, char* moduleName) initInterp(StudyID); interp->enter(); + /* + * SetSettings is called when changing component (python module) + * Get the right module + * As module is a static in the shared library we need to restore the module + * + */ + module=PyImport_ImportModule((char*)_moduleName.c_str()); + if (module == NULL) + { + MESSAGE ( " Problem... " ); + PyErr_Print(); + interp->quit(); + return false; + } res=PyObject_CallMethod(module,"setSettings",""); if (res == NULL) { -- 2.39.2