From: mzn Date: Fri, 19 Sep 2008 12:45:12 +0000 (+0000) Subject: Fix for IPAL20242 (Qt4 porting: SIGSEGV on several studies). X-Git-Tag: TG_TRIPOLI_qt4_porting X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3979c8bccc661510caa879f1bfbb9c1378a34ae7;p=modules%2Fgui.git Fix for IPAL20242 (Qt4 porting: SIGSEGV on several studies). --- diff --git a/src/SalomeApp/SalomeApp_VisualState.cxx b/src/SalomeApp/SalomeApp_VisualState.cxx index a3f14ddb6..e3de909d9 100644 --- a/src/SalomeApp/SalomeApp_VisualState.cxx +++ b/src/SalomeApp/SalomeApp_VisualState.cxx @@ -43,7 +43,8 @@ Constructor. */ SalomeApp_VisualState::SalomeApp_VisualState( SalomeApp_Application* app ) - : myApp( app ) + : QObject(), + myApp( app ) { } @@ -192,6 +193,8 @@ void SalomeApp_VisualState::restoreState(int savePoint) _PTR(AttributeParameter) ap = study->studyDS()->GetCommonParameters( study->getVisualComponentName(), savePoint ); _PTR(IParameters) ip = ClientFactory::getIParameters(ap); + qApp->installEventFilter( this ); + //Remove all already existent veiwers and their views ViewManagerList lst; myApp->viewManagers( lst ); @@ -206,7 +209,7 @@ void SalomeApp_VisualState::restoreState(int savePoint) // parameters of view windows are stored in a map for restoring after restoring of the workstack QMap viewersParameters; - + for ( int i = 0; i < nbViewers; i++ ) { std::string viewerEntry = ip->getValue( "AP_VIEWERS_LIST", i ); std::vector veiewerParams = ip->parseValue(viewerEntry,'_'); @@ -303,6 +306,8 @@ void SalomeApp_VisualState::restoreState(int savePoint) if ( activeViewName == mapIt.key()->objectName().toStdString() ) mapIt.key()->setFocus(); } + + qApp->removeEventFilter( this ); // for ( it.toFirst(); it.current(); ++it ) { // int view_count = it.current()->getViewsCount(); @@ -322,3 +327,21 @@ void SalomeApp_VisualState::restoreState(int savePoint) // } // } } + +/*! + Custom event filter +*/ +bool SalomeApp_VisualState::eventFilter( QObject* o, QEvent* e ) +{ + // eat keyboard and mouse events + QEvent::Type aType = e->type(); + if ( aType == QEvent::MouseButtonDblClick || + aType == QEvent::MouseButtonPress || + aType == QEvent::MouseButtonRelease || + aType == QEvent::MouseMove || + aType == QEvent::KeyPress || + aType == QEvent::KeyRelease ) + return true; + + return QObject::eventFilter( o, e ); +} diff --git a/src/SalomeApp/SalomeApp_VisualState.h b/src/SalomeApp/SalomeApp_VisualState.h index dae7fc091..129cb2fe6 100644 --- a/src/SalomeApp/SalomeApp_VisualState.h +++ b/src/SalomeApp/SalomeApp_VisualState.h @@ -25,9 +25,11 @@ #include "SalomeApp.h" +#include + class SalomeApp_Application; -class SALOMEAPP_EXPORT SalomeApp_VisualState +class SALOMEAPP_EXPORT SalomeApp_VisualState: public QObject { public: SalomeApp_VisualState( SalomeApp_Application* ); @@ -36,6 +38,9 @@ public: virtual int storeState(); virtual void restoreState( int savePoint ); +private: + virtual bool eventFilter( QObject* o, QEvent* e ); + protected: SalomeApp_Application* myApp; };