From: Friedemann Kleint Date: Thu, 24 May 2012 13:53:09 +0000 (+0200) Subject: QtWidgets: Fix QT_FLUSH_UPDATE for Windows. X-Git-Tag: 071012110112~818 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d74c45a95bd3c9195129e9be495a38b5a0218acf;p=profile%2Fivi%2Fqtbase.git QtWidgets: Fix QT_FLUSH_UPDATE for Windows. Change-Id: I09fd1ca6e7691b326760b83aad612e9a26717379 Reviewed-by: Girish Ramakrishnan --- diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index eb86f25..a9b43e7 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -57,6 +57,11 @@ #include #include +#if defined(Q_OS_WIN) && !defined(QT_NO_PAINT_DEBUG) +# include +# include +#endif + QT_BEGIN_NAMESPACE extern QRegion qt_dirtyRegion(QWidget *); @@ -115,9 +120,19 @@ static inline void qt_flush(QWidget *widget, const QRegion ®ion, QBackingStor } #ifndef QT_NO_PAINT_DEBUG -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN + static void showYellowThing_win(QWidget *widget, const QRegion ®ion, int msec) { + // We expect to be passed a native parent. + QWindow *nativeWindow = widget->windowHandle(); + if (!nativeWindow) + return; + void *hdcV = QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("getDC"), nativeWindow); + if (!hdcV) + return; + const HDC hdc = reinterpret_cast(hdcV); + HBRUSH brush; static int i = 0; switch (i) { @@ -136,19 +151,16 @@ static void showYellowThing_win(QWidget *widget, const QRegion ®ion, int msec } i = (i + 1) & 3; - HDC hdc = widget->getDC(); - - const QVector &rects = region.rects(); - foreach (QRect rect, rects) { + foreach (const QRect &rect, region.rects()) { RECT winRect; SetRect(&winRect, rect.left(), rect.top(), rect.right(), rect.bottom()); FillRect(hdc, &winRect, brush); } - - widget->releaseDC(hdc); + DeleteObject(brush); + QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("releaseDC"), nativeWindow); ::Sleep(msec); } -#endif +#endif // Q_OS_WIN void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePainted, int msec, bool unclipped) { @@ -163,7 +175,7 @@ void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePa widget = nativeParent; } -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN Q_UNUSED(unclipped); showYellowThing_win(widget, paintRegion, msec); #else @@ -215,7 +227,7 @@ void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePa #if defined(Q_OS_UNIX) ::usleep(1000 * msec); #endif -#endif // Q_WS_WIN +#endif // !Q_OS_WIN } bool QWidgetBackingStore::flushPaint(QWidget *widget, const QRegion &rgn)