From: mzn Date: Fri, 1 Sep 2006 14:31:35 +0000 (+0000) Subject: Fix for bug PAL13324(EDF263 SMESH: SIGSEGV if changing study in the Create Hypothesis... X-Git-Tag: V3_2_2pre~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a54e5ba182a59e9de3812b465801b2a266b96b13;p=modules%2Fgui.git Fix for bug PAL13324(EDF263 SMESH: SIGSEGV if changing study in the Create Hypothesis dialog Box). --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index ab5e1e597..0c3d7c81c 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -38,6 +38,8 @@ #include "LightApp_OBFilter.h" +#include "LightApp_EventFilter.h" + #include "LightApp_OBSelector.h" #include "LightApp_SelectionMgr.h" @@ -296,6 +298,8 @@ void LightApp_Application::start() putInfo( "" ); desktop()->statusBar()->message( "" ); + + LightApp_EventFilter::Init(); } /*!Gets application name.*/ diff --git a/src/LightApp/LightApp_EventFilter.cxx b/src/LightApp/LightApp_EventFilter.cxx new file mode 100644 index 000000000..77ab42c9f --- /dev/null +++ b/src/LightApp/LightApp_EventFilter.cxx @@ -0,0 +1,81 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "LightApp_EventFilter.h" + +#include + +#include + +LightApp_EventFilter* LightApp_EventFilter::myFilter = NULL; + +/*!Constructor.*/ +LightApp_EventFilter::LightApp_EventFilter() +: QObject() +{ + qApp->installEventFilter( this ); +} + +/*!Destructor.*/ +LightApp_EventFilter::~LightApp_EventFilter() +{ + qApp->removeEventFilter( this ); +} + +/*! + Custom event filter +*/ +bool LightApp_EventFilter::eventFilter( QObject* o, QEvent* e ) +{ + if ( e->type() == QEvent::WindowActivate && o->inherits("QDialog") ) + { + QWidget* parent = ((QWidget*)o)->parentWidget(); + + SUIT_Desktop* aDesktop = 0; + + while( parent ) + { + if ( aDesktop = dynamic_cast(parent) ) + break; + parent = parent->parentWidget(); + } + + if ( aDesktop ) + aDesktop->emitActivated(); + } + + return QObject::eventFilter( o, e ); +} + +/*!Create new instance of LightApp_EventFilter*/ +void LightApp_EventFilter::Init() +{ + if( myFilter==NULL ) + myFilter = new LightApp_EventFilter(); +} + +/*!Destroy filter.*/ +void LightApp_EventFilter::Destroy() +{ + if( myFilter ) + { + delete myFilter; + myFilter = NULL; + } +} diff --git a/src/LightApp/LightApp_EventFilter.h b/src/LightApp/LightApp_EventFilter.h new file mode 100644 index 000000000..836db4476 --- /dev/null +++ b/src/LightApp/LightApp_EventFilter.h @@ -0,0 +1,56 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef LIGHTAPP_EVENTFILTER_H +#define LIGHTAPP_EVENTFILTER_H + +#include "LightApp.h" + +#include + +#if defined WNT +#pragma warning( disable: 4251 ) +#endif + +/*! + Class provide event filter. +*/ +class LIGHTAPP_EXPORT LightApp_EventFilter: public QObject +{ +public: + static void Init(); + static void Destroy(); + +protected: + LightApp_EventFilter(); + virtual ~LightApp_EventFilter(); + +private: + /*! global event filter for qapplication */ + virtual bool eventFilter( QObject* o, QEvent* e ); + +private: + static LightApp_EventFilter* myFilter; +}; + +#if defined WNT +#pragma warning( default: 4251 ) +#endif + +#endif diff --git a/src/LightApp/Makefile.in b/src/LightApp/Makefile.in index 2fd596ee3..eb1cef66f 100755 --- a/src/LightApp/Makefile.in +++ b/src/LightApp/Makefile.in @@ -40,6 +40,7 @@ EXPORT_HEADERS= LightApp.h \ LightApp_Dialog.h \ LightApp_Displayer.h \ LightApp_Driver.h \ + LightApp_EventFilter.h \ LightApp_HDFDriver.h \ LightApp_Module.h \ LightApp_ModuleDlg.h \ @@ -86,6 +87,7 @@ LIB_SRC= LightApp_AboutDlg.cxx \ LightApp_Dialog.cxx \ LightApp_Displayer.cxx \ LightApp_Driver.cxx \ + LightApp_EventFilter.cxx \ LightApp_HDFDriver.cxx \ LightApp_Module.cxx \ LightApp_ModuleDlg.cxx \ diff --git a/src/SUIT/SUIT_Desktop.cxx b/src/SUIT/SUIT_Desktop.cxx index 6c6bcb37e..8d75c7174 100755 --- a/src/SUIT/SUIT_Desktop.cxx +++ b/src/SUIT/SUIT_Desktop.cxx @@ -171,4 +171,10 @@ void SUIT_Desktop::logoClear() myLogoMgr->clear(); } - +/*! + Emits activated signal +*/ +void SUIT_Desktop::emitActivated() +{ + emit activated(); +} diff --git a/src/SUIT/SUIT_Desktop.h b/src/SUIT/SUIT_Desktop.h index d63657956..a346d0ca4 100755 --- a/src/SUIT/SUIT_Desktop.h +++ b/src/SUIT/SUIT_Desktop.h @@ -59,6 +59,8 @@ public: void logoRemove( const QString& ); void logoInsert( const QString&, const QPixmap&, const int = -1 ); + void emitActivated(); + signals: void activated(); void deactivated();