#include <PyInterp_Dispatcher.h>
#include <SUIT_Tools.h>
+#include <SUIT_Session.h>
#include <qmap.h>
#include <qclipboard.h>
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;
#include <dlfcn.h>
#endif
+static bool SUIT_Session_IsPythonExecuted = false;
+static QMutex SUIT_Session_PythonMutex;
+
SUIT_Session* SUIT_Session::mySession = 0;
/*! Constructor.*/
{
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();
+}
#include "SUIT_Application.h"
#include "SUIT_ResourceMgr.h"
+#include <qmutex.h>
#include <qobject.h>
#include <qptrlist.h>
#include <qptrvector.h>
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* );
//
#include "SUITApp_Application.h"
+#include "SUIT_Session.h"
#include "SUIT_MessageBox.h"
#include "SUIT_ExceptionHandler.h"
*/
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 );
}
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 );
}