]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PAL12651: EDF: Crash on a biprocessor machine. Disable GUI user actions while a pytho...
authorjfa <jfa@opencascade.com>
Thu, 29 Jun 2006 13:30:07 +0000 (13:30 +0000)
committerjfa <jfa@opencascade.com>
Thu, 29 Jun 2006 13:30:07 +0000 (13:30 +0000)
src/PythonConsole/PythonConsole_PyEditor.cxx
src/SUIT/SUIT_Session.cxx
src/SUIT/SUIT_Session.h
src/SUITApp/SUITApp_Application.cxx
src/Session/SALOME_Session_Server.cxx

index 3093b89de88e8df55622b7482c69751e0799c86c..ed75e1f5b4e2ed5cc423d76ad6c915d41727ebbb 100755 (executable)
@@ -30,6 +30,7 @@
 #include <PyInterp_Dispatcher.h>
 
 #include <SUIT_Tools.h>
+#include <SUIT_Session.h>
 
 #include <qmap.h>
 #include <qclipboard.h>
@@ -66,7 +67,9 @@ protected:
   virtual void execute(){
     if(myCommand != ""){
 //      if(MYDEBUG) MESSAGE("*** ExecCommand::execute() started");
+      SUIT_Session::SetPythonExecuted(true); // disable GUI user actions
       int ret = getInterp()->run( myCommand.latin1() );
+      SUIT_Session::SetPythonExecuted(false); // enable GUI user actions
 //      if(MYDEBUG) MESSAGE("ExecCommand::execute() - myInterp = "<<getInterp()<<"; myCommand = '"<<myCommand.latin1()<<"' - "<<ret);
       if(ret < 0)
        myState = PyInterp_Event::ERROR;
index 6d5f0669dda3d121dff1d413188cb09d2d338ba5..0e641f236e41676d82ed75884eeaa4537c973079 100755 (executable)
@@ -35,6 +35,9 @@
 #include <dlfcn.h>
 #endif
 
+static bool   SUIT_Session_IsPythonExecuted = false;
+static QMutex SUIT_Session_PythonMutex;
+
 SUIT_Session* SUIT_Session::mySession = 0;
 
 /*! Constructor.*/
@@ -323,3 +326,28 @@ void SUIT_Session::onApplicationActivated( SUIT_Application* app )
 {
   myActiveApp = app;
 }
+
+/*!
+  \retval Return TRUE, if a command is currently executed in Python Console,
+                 FALSE otherwise.
+*/
+bool SUIT_Session::IsPythonExecuted()
+{
+  bool ret;
+  SUIT_Session_PythonMutex.lock();
+  ret = SUIT_Session_IsPythonExecuted;
+  SUIT_Session_PythonMutex.unlock();
+  return ret;
+}
+
+/*!
+  Set value of boolean flag, being returned by method \a IsPythonExecuted().
+  It is supposed to set the flag to TRUE when any python command starts
+  and reset it to FALSE when the command finishes.
+*/
+void SUIT_Session::SetPythonExecuted(bool isPythonExecuted)
+{
+  SUIT_Session_PythonMutex.lock();
+  SUIT_Session_IsPythonExecuted = isPythonExecuted;
+  SUIT_Session_PythonMutex.unlock();
+}
index 08078ff74f9dc6c6f0dc7f32ce4b3da90b0c743d..840de59278bdb8935bad7aaf03ba8146464dac0a 100755 (executable)
@@ -24,6 +24,7 @@
 #include "SUIT_Application.h"
 #include "SUIT_ResourceMgr.h"
 
+#include <qmutex.h>
 #include <qobject.h>
 #include <qptrlist.h>
 #include <qptrvector.h>
@@ -73,6 +74,10 @@ public:
 
   SUIT_ExceptionHandler*       handler() const;
 
+  // To lock GUI user actions during python command execution (PAL12651)
+  static bool                  IsPythonExecuted();
+  static void                  SetPythonExecuted(bool isPythonExecuted);
+
 signals:
   void                         applicationClosed( SUIT_Application* );
 
index 4639f100d79933cce38cbf6c192eed56eca62494..7fe9b33a354391ee2657d85ccf343e4b7e5e6745 100644 (file)
@@ -18,6 +18,7 @@
 //
 #include "SUITApp_Application.h"
 
+#include "SUIT_Session.h"
 #include "SUIT_MessageBox.h"
 #include "SUIT_ExceptionHandler.h"
 
@@ -68,6 +69,18 @@ myExceptHandler( hand )
 */
 bool SUITApp_Application::notify( QObject* receiver, QEvent* e )
 {
+  // Disable GUI user actions while python command is executed
+  if (SUIT_Session::IsPythonExecuted()) {
+    // Disable mouse and keyboard events
+    QEvent::Type aType = e->type();
+    if (aType == QEvent::MouseButtonPress || aType == QEvent::MouseButtonRelease ||
+        aType == QEvent::MouseButtonDblClick || aType == QEvent::MouseMove ||
+        aType == QEvent::Wheel ||
+        aType == QEvent::KeyPress || aType == QEvent::KeyRelease ||
+        aType == QEvent::Accel || aType == QEvent::AccelOverride)
+      return false;
+  }
+
   return myExceptHandler ? myExceptHandler->handle( receiver, e ) :
                            QApplication::notify( receiver, e );
 }
index 21ceec290f13fb492e95ea3f5d60521f462abc98..d278421c164ec92ba8ea9912771e3a68e7841c77 100755 (executable)
@@ -246,6 +246,18 @@ public:
 
   virtual bool notify( QObject* receiver, QEvent* e )
   {
+    // Disable GUI user actions while python command is executed
+    if (SUIT_Session::IsPythonExecuted()) {
+      // Disable mouse and keyboard events
+      QEvent::Type aType = e->type();
+      if (aType == QEvent::MouseButtonPress || aType == QEvent::MouseButtonRelease ||
+          aType == QEvent::MouseButtonDblClick || aType == QEvent::MouseMove ||
+          aType == QEvent::Wheel ||
+          aType == QEvent::KeyPress || aType == QEvent::KeyRelease ||
+          aType == QEvent::Accel || aType == QEvent::AccelOverride)
+        return false;
+    }
+
     return myHandler ? myHandler->handle( receiver, e ) :
       QApplication::notify( receiver, e );
   }