Salome HOME
Alternative implementation, with catching custom event vsr/qtesting
authorvsr <vsr@opencascade.com>
Thu, 21 Apr 2016 15:57:18 +0000 (18:57 +0300)
committervsr <vsr@opencascade.com>
Thu, 21 Apr 2016 15:57:18 +0000 (18:57 +0300)
src/MEDCalc/gui/TestController.cxx
src/MEDCalc/gui/TestController.hxx

index c9d71efd190e10448cb1bc0e380295814f587503..dfb9979228e8eb3ac668a3c95cf81b05e44d6d4c 100644 (file)
@@ -68,7 +68,8 @@ TestController::TestController(MEDModule* mod):
   _tester->addEventObserver("xml", new pqXMLEventObserver(_desk));
   _tester->addEventSource("xml", new pqXMLEventSource(_desk));
 
-  QTimer::singleShot(0, this, SLOT(onMainEventLoopStarting()));
+  QApplication::instance()->installEventFilter(this);
+  //QTimer::singleShot(0, this, SLOT(onMainEventLoopStarting()));
 }
 
 TestController::~TestController()
@@ -213,4 +214,12 @@ TestController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
 void TestController::onMainEventLoopStarting()
 {
   _myEventLoopStarted = true;
+  QApplication::instance()->removeEventFilter(this);
+}
+
+bool TestController::eventFilter(QObject *obj, QEvent *event)
+{
+  if ( obj == QApplication::instance() && event->type() == 9999 )
+    onMainEventLoopStarting();
+  return QObject::eventFilter(obj, event);
 }
index ed8295c1caef5e21a5ccec0808c5b6ba3e952e69..d78557e1fb17d6812fdcfc28a3aaf9640a854545 100644 (file)
@@ -42,6 +42,8 @@ public:
 
   bool isMainEventLoopStarted() const { return _myEventLoopStarted; }
 
+  bool eventFilter(QObject *obj, QEvent *event);
+  
 protected:
   virtual void customEvent(QEvent * event);