]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix for bug PAL13324(EDF263 SMESH: SIGSEGV if changing study in the Create Hypothesis...
authormzn <mzn@opencascade.com>
Fri, 1 Sep 2006 14:31:35 +0000 (14:31 +0000)
committermzn <mzn@opencascade.com>
Fri, 1 Sep 2006 14:31:35 +0000 (14:31 +0000)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_EventFilter.cxx [new file with mode: 0644]
src/LightApp/LightApp_EventFilter.h [new file with mode: 0644]
src/LightApp/Makefile.in
src/SUIT/SUIT_Desktop.cxx
src/SUIT/SUIT_Desktop.h

index ab5e1e597619f978bcde00eca94eae8ad560c4c0..0c3d7c81c4f8a5e060e4d0d83a1b7ffe0a31ce38 100644 (file)
@@ -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 (file)
index 0000000..77ab42c
--- /dev/null
@@ -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 <SUIT_Desktop.h>
+
+#include <qapplication.h>
+
+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<SUIT_Desktop*>(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 (file)
index 0000000..836db44
--- /dev/null
@@ -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 <qobject.h>
+
+#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
index 2fd596ee31dae2a179631fb1c40af059eaeede8d..eb1cef66f767eda6eb41ce570f143ee06809598b 100755 (executable)
@@ -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 \
index 6c6bcb37e8632891bb6753a0ea6f6a9f5d9b9a56..8d75c71740806e3794afa08c176d8866b4fede62 100755 (executable)
@@ -171,4 +171,10 @@ void SUIT_Desktop::logoClear()
     myLogoMgr->clear();
 }
 
-
+/*!
+  Emits activated signal
+*/
+void SUIT_Desktop::emitActivated()
+{
+  emit activated();
+}
index d63657956e981fe9075c10a46aa69680a7ced01c..a346d0ca499f0531d5db55c2a33006ee8660d1c4 100755 (executable)
@@ -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();