diff options
author | Stanislav Ionascu <stanislav.ionascu@nokia.com> | 2010-12-15 13:36:41 +0200 |
---|---|---|
committer | Stanislav Ionascu <stanislav.ionascu@nokia.com> | 2010-12-15 13:54:13 +0200 |
commit | f34f7becafebd25862c31986d87848db1ad6ef69 (patch) | |
tree | 242863e052fbc00e6980fecf6c55fab0045787ac | |
parent | e57ebef2101fed7fcd3fdcb0303d5f8ffa2f020b (diff) |
Changes: Allow empty main loop helper to quit on request.
RevBy: Armin Berres
-rw-r--r-- | benchmarks/performancebenchmark/emptymainloophelper.cpp | 11 | ||||
-rw-r--r-- | benchmarks/performancebenchmark/emptymainloophelper.h | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/benchmarks/performancebenchmark/emptymainloophelper.cpp b/benchmarks/performancebenchmark/emptymainloophelper.cpp index ba08e770..15bcae42 100644 --- a/benchmarks/performancebenchmark/emptymainloophelper.cpp +++ b/benchmarks/performancebenchmark/emptymainloophelper.cpp @@ -38,6 +38,7 @@ EmptyMainLoopHelper::EmptyMainLoopHelper() : terminationType( QuitOnEmpty ) { + readyToQuit = false; } void EmptyMainLoopHelper::triggerTermination(TerminationType type) @@ -49,7 +50,7 @@ void EmptyMainLoopHelper::triggerTermination(TerminationType type) void EmptyMainLoopHelper::terminateOnEmptyMainLoop() { qApp->processEvents(); - if (qApp->hasPendingEvents() || MTheme::hasPendingRequests()) { + if ((qApp->hasPendingEvents() || MTheme::hasPendingRequests()) && !readyToQuit) { QTimer::singleShot(0, this, SLOT(terminateOnEmptyMainLoop())); } else { QTimer::singleShot(20, this, SLOT(terminateOnEmptyMainLoop2())); @@ -58,7 +59,7 @@ void EmptyMainLoopHelper::terminateOnEmptyMainLoop() void EmptyMainLoopHelper::terminateOnEmptyMainLoop2() { - if (qApp->hasPendingEvents()) { + if (qApp->hasPendingEvents() && !readyToQuit) { QTimer::singleShot(0, this, SLOT(terminateOnEmptyMainLoop())); } else { if (terminationType == ExitOnEmpty) { @@ -73,9 +74,13 @@ void EmptyMainLoopHelper::terminateOnEmptyMainLoop2() .arg((int)t.tv_sec) .arg((int)(t.tv_usec % 1000000), 6, 10, (const QChar)'0'); #endif - qApp->quit(); } } } +void EmptyMainLoopHelper::quit() +{ + readyToQuit = true; +} + diff --git a/benchmarks/performancebenchmark/emptymainloophelper.h b/benchmarks/performancebenchmark/emptymainloophelper.h index 32513995..ed53eb19 100644 --- a/benchmarks/performancebenchmark/emptymainloophelper.h +++ b/benchmarks/performancebenchmark/emptymainloophelper.h @@ -51,8 +51,11 @@ public slots: */ void terminateOnEmptyMainLoop2(); + void quit(); + private: TerminationType terminationType; + bool readyToQuit; }; #endif // EMPTYMAINLOOPHELPER_H |