From 665eb0d1cc1460935a85bbe1e7760492071474c6 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 21 Apr 2016 18:57:18 +0300 Subject: [PATCH] Alternative implementation, with catching custom event --- src/MEDCalc/gui/TestController.cxx | 11 ++++++++++- src/MEDCalc/gui/TestController.hxx | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/MEDCalc/gui/TestController.cxx b/src/MEDCalc/gui/TestController.cxx index c9d71efd1..dfb997922 100644 --- a/src/MEDCalc/gui/TestController.cxx +++ b/src/MEDCalc/gui/TestController.cxx @@ -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); } diff --git a/src/MEDCalc/gui/TestController.hxx b/src/MEDCalc/gui/TestController.hxx index ed8295c1c..d78557e1f 100644 --- a/src/MEDCalc/gui/TestController.hxx +++ b/src/MEDCalc/gui/TestController.hxx @@ -42,6 +42,8 @@ public: bool isMainEventLoopStarted() const { return _myEventLoopStarted; } + bool eventFilter(QObject *obj, QEvent *event); + protected: virtual void customEvent(QEvent * event); -- 2.39.2