Salome HOME
Copyright update 2022
[modules/med.git] / src / MEDCalc / gui / TestController.cxx
index c9d71efd190e10448cb1bc0e380295814f587503..f1abfa55f098fb5632e2c0e55bdb2adcd9f9d0b1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2016  CEA/DEN, EDF R&D
+// Copyright (C) 2016-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -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);
 }