diff options
author | Armin Berres <armin.berres@basyskom.de> | 2010-05-10 13:15:38 +0200 |
---|---|---|
committer | Sergiy Dubovik <sergiy.dubovik@nokia.com> | 2010-05-11 09:12:48 +0300 |
commit | 8d334aab935c3497a9c165f253fb49f2baa67d26 (patch) | |
tree | 374948738a0824d14cc955b29c9c31664ea8729e | |
parent | 1476306117a4245f69ef24c9e87d121031a2ebe0 (diff) |
Changes: make sure timedemo fails if no or a broken window manager is running
RevBy: TrustMe
Details:
If no windowmanager is running or a broken window manager is running pages
cannot be activated properly. This commit introduces a timer which makes
sure the page has really been activated and terminates the application with
a warning otherwise.
-rw-r--r-- | demos/widgetsgallery/panningbenchmark.cpp | 2 | ||||
-rw-r--r-- | demos/widgetsgallery/staticpagebenchmark.cpp | 2 | ||||
-rw-r--r-- | demos/widgetsgallery/timedemobenchmark.cpp | 15 | ||||
-rw-r--r-- | demos/widgetsgallery/timedemobenchmark.h | 10 |
4 files changed, 29 insertions, 0 deletions
diff --git a/demos/widgetsgallery/panningbenchmark.cpp b/demos/widgetsgallery/panningbenchmark.cpp index 498166be..845e0403 100644 --- a/demos/widgetsgallery/panningbenchmark.cpp +++ b/demos/widgetsgallery/panningbenchmark.cpp @@ -47,6 +47,7 @@ void PanningBenchmark::start() if (!applicationPage->isActiveWindow()) { connect(applicationPage, SIGNAL(appeared()), this, SLOT(waitBeforePanning())); applicationPage->appear(); + verifyAppearanceTimer->start(2000); } else { waitBeforePanning(); } @@ -56,6 +57,7 @@ void PanningBenchmark::start() // the widgets are not completely set up yet void PanningBenchmark::waitBeforePanning() { + verifyAppearanceTimer->stop(); QTimer::singleShot(2500, this, SLOT(panDown())); } diff --git a/demos/widgetsgallery/staticpagebenchmark.cpp b/demos/widgetsgallery/staticpagebenchmark.cpp index ba312f6e..96377f10 100644 --- a/demos/widgetsgallery/staticpagebenchmark.cpp +++ b/demos/widgetsgallery/staticpagebenchmark.cpp @@ -29,12 +29,14 @@ void StaticPageBenchmark::start() if (!applicationPage->isActiveWindow()) { connect(applicationPage, SIGNAL(appeared()), this, SLOT(stabilizeFps())); applicationPage->appear(); + verifyAppearanceTimer->start(2000); } else { QTimer::singleShot(0, this, SLOT(stabilizeFps())); } } void StaticPageBenchmark::stabilizeFps() { + verifyAppearanceTimer->stop(); QTimer::singleShot(1000, this, SLOT(waitPageDuration())); } diff --git a/demos/widgetsgallery/timedemobenchmark.cpp b/demos/widgetsgallery/timedemobenchmark.cpp index b1a2d619..0a2532a6 100644 --- a/demos/widgetsgallery/timedemobenchmark.cpp +++ b/demos/widgetsgallery/timedemobenchmark.cpp @@ -1,10 +1,15 @@ #include "timedemobenchmark.h" +#include <QTimer> +#include <MApplicationPage> + TimedemoBenchmark::TimedemoBenchmark(MApplicationPage *applicationPage, Timedemo *timedemo) : applicationPage(applicationPage) , timedemo(timedemo) , _type("common") { + verifyAppearanceTimer = new QTimer(this); + connect(verifyAppearanceTimer, SIGNAL(timeout()), this, SLOT(terminateIfNotAppeared())); } QString TimedemoBenchmark::type() { @@ -14,3 +19,13 @@ QString TimedemoBenchmark::type() { void TimedemoBenchmark::setType(const QString& type) { _type = type; } + +void TimedemoBenchmark::terminateIfNotAppeared() { + verifyAppearanceTimer->stop(); + if (applicationPage->isActiveWindow()) { + return; + } else { + qCritical("Could not activate application page. Is a window manager running?"); + exit(EXIT_FAILURE); + } +} diff --git a/demos/widgetsgallery/timedemobenchmark.h b/demos/widgetsgallery/timedemobenchmark.h index 89440d4e..22c90b83 100644 --- a/demos/widgetsgallery/timedemobenchmark.h +++ b/demos/widgetsgallery/timedemobenchmark.h @@ -6,6 +6,7 @@ class MApplicationPage; class Timedemo; class QString; +class QTimer; /** * TimedemoBenchmark is the base class for all benchmarks used in the timedemo. @@ -52,7 +53,16 @@ signals: */ void finished(); +protected slots: + void terminateIfNotAppeared(); + protected: + /** + * Start this timer after calling MApplicationPage::appear() to verify the application page + * has really appeared/is really active. + * Timer will terminate the application after the timeout if page is not active. + */ + QTimer *verifyAppearanceTimer; MApplicationPage *applicationPage; Timedemo *timedemo; QString _type; |