_tester(0), _lock_action(0),
_quitEventType(QEvent::registerEventType()),
_playEventType(QEvent::registerEventType()),
- _aboutToPlayTest(false)
+ _aboutToPlayTest(false),
+ _myEventLoopStarted(false)
{
STDLOG("Creating a TestController");
_tester = new pqTestUtility(_desk);
_tester->addEventObserver("xml", new pqXMLEventObserver(_desk));
_tester->addEventSource("xml", new pqXMLEventSource(_desk));
+
+ QApplication::instance()->installEventFilter(this);
+ //QTimer::singleShot(0, this, SLOT(onMainEventLoopStarting()));
}
TestController::~TestController()
{
if (event->type() == _quitEventType)
{
- if(!_salomeModule->getApp()->isMainEventLoopStarted())
+ if(!isMainEventLoopStarted())
// Repost (=delay)
QApplication::postEvent(this, new QEvent((QEvent::Type)_quitEventType));
else
if (e)
{
// // Wait for main event loop to start:
- if(!_salomeModule->getApp()->isMainEventLoopStarted())
+ if(!isMainEventLoopStarted())
// Repost (=delay)
QApplication::postEvent(this, new PlayTestEvent((QEvent::Type)_playEventType, e->_filename));
else
}
}
+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);
+}
void createActions();
+ bool isMainEventLoopStarted() const { return _myEventLoopStarted; }
-
+ bool eventFilter(QObject *obj, QEvent *event);
+
protected:
virtual void customEvent(QEvent * event);
pqTestUtility * _tester;
QAction * _lock_action;
+private slots:
+ void onMainEventLoopStarting();
+
private:
const int _playEventType;
const int _quitEventType;
bool _aboutToPlayTest;
+
+ bool _myEventLoopStarted;
};
#endif /* SRC_MEDCALC_GUI_TESTCONTROLLER_HXX_ */