From 4a25f9103b2edbb1eb05351da3e576d73d9dbda8 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Thu, 7 Jan 2010 23:05:45 -0500 Subject: [PATCH] BUG: On Macs, the test playback is relying on timeouts to detect modal dialogs. Now, this timeout can happen, even when we are not really waiting a modal dialog's exec() e.g. when we are simply waiting for a short time for the GUI to refresh. This was resulting in the test playing continuing oddly causing some tests that use too many modal dialogs to fail. This should fix that that issue. --- pqEventDispatcher.cxx | 15 +++++++++++++++ pqEventDispatcher.h | 1 + 2 files changed, 16 insertions(+) diff --git a/pqEventDispatcher.cxx b/pqEventDispatcher.cxx index 11c7c88..a6b8728 100644 --- a/pqEventDispatcher.cxx +++ b/pqEventDispatcher.cxx @@ -48,6 +48,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include using namespace std; +bool pqEventDispatcher::DeferMenuTimeouts = false; //----------------------------------------------------------------------------- pqEventDispatcher::pqEventDispatcher(QObject* parentObject) : Superclass(parentObject) @@ -176,6 +177,8 @@ void pqEventDispatcher::playEventStack(void* activeWidget) //----------------------------------------------------------------------------- void pqEventDispatcher::processEventsAndWait(int ms) { + bool prev = pqEventDispatcher::DeferMenuTimeouts; + pqEventDispatcher::DeferMenuTimeouts = true; if (ms > 0) { QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); @@ -184,11 +187,23 @@ void pqEventDispatcher::processEventsAndWait(int ms) loop.exec(QEventLoop::ExcludeUserInputEvents); } QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + pqEventDispatcher::DeferMenuTimeouts = prev; } //----------------------------------------------------------------------------- void pqEventDispatcher::onMenuTimerTimeout() { + // this is used to capture cases where are popup-menu (or any modal dialog in + // case of APPLE) is active in its event loop. However, we don't want the + // test to proceed if this timeout happened while we were in the + // processEventsAndWait() loop at any stage in executing an event. So we have + // this trap. + if (pqEventDispatcher::DeferMenuTimeouts) + { + this->AdhocMenuTimer.start(); + return; + } + QWidget* currentPopup = QApplication::activePopupWidget(); #if defined(__APPLE__) if (!currentPopup) diff --git a/pqEventDispatcher.h b/pqEventDispatcher.h index 4b2de6a..1843bc5 100644 --- a/pqEventDispatcher.h +++ b/pqEventDispatcher.h @@ -82,6 +82,7 @@ protected slots: protected: bool PlayBackFinished; bool PlayBackStatus; + static bool DeferMenuTimeouts; pqEventSource* ActiveSource; pqEventPlayer* ActivePlayer; -- GitLab