summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qsplashscreen.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-07-16 12:22:04 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-16 14:22:55 +0200
commit117b27dc8d1ff970e3da1c0e85c91406e782b53e (patch)
tree05419f35e47a1be24522437c14b13d9b634fa32c /src/widgets/widgets/qsplashscreen.cpp
parent59096732f6fe9b922df2dd65c9eff4edcc444ce2 (diff)
Fix QSplashScreen on X11.
Use code from QTestLib to wait for the Window to show up. Change-Id: Ib674f3eb7a6c32cad1d502caefe7d4b073754e73 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Diffstat (limited to 'src/widgets/widgets/qsplashscreen.cpp')
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index f3a19c88ec..b640c7890a 100644
--- a/src/widgets/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
@@ -49,9 +49,17 @@
#include "qpixmap.h"
#include "qtextdocument.h"
#include "qtextcursor.h"
+#include <QtGui/qwindow.h>
#include <QtCore/qdebug.h>
+#include <QtCore/qelapsedtimer.h>
#include <private/qwidget_p.h>
+#ifdef Q_OS_WIN
+# include <QtCore/qt_windows.h>
+#else
+# include <time.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QSplashScreenPrivate : public QWidgetPrivate
@@ -217,18 +225,37 @@ void QSplashScreen::clearMessage()
repaint();
}
+// A copy of QTestLib's qWaitForWindowExposed() and qSleep().
+inline static bool waitForWindowExposed(QWindow *window, int timeout = 1000)
+{
+ enum { TimeOutMs = 10 };
+ QElapsedTimer timer;
+ timer.start();
+ while (!window->isExposed()) {
+ const int remaining = timeout - int(timer.elapsed());
+ if (remaining <= 0)
+ break;
+ QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+#ifdef Q_OS_WIN
+ Sleep(uint(TimeOutMs));
+#else
+ struct timespec ts = { TimeOutMs / 1000, (TimeOutMs % 1000) * 1000 * 1000 };
+ nanosleep(&ts, NULL);
+#endif
+ }
+ return window->isExposed();
+}
+
/*!
Makes the splash screen wait until the widget \a mainWin is displayed
before calling close() on itself.
*/
+
void QSplashScreen::finish(QWidget *mainWin)
{
- if (mainWin) {
-#if defined(Q_WS_X11)
- extern void qt_x11_wait_for_window_manager(QWidget *mainWin, bool);
- qt_x11_wait_for_window_manager(mainWin, false);
-#endif
- }
+ if (mainWin && mainWin->windowHandle())
+ waitForWindowExposed(mainWin->windowHandle());
close();
}