summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2017-04-20 16:07:06 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2017-04-22 15:18:01 +0000
commit41eefd7493bf0119a4fd1a069e31ab4f2c4d10f9 (patch)
treeb9f8c363961d27939894c63d7d065ad247779656 /src/widgets/widgets
parentd4cdc4542609e61d04802902d73c693faa8d8969 (diff)
Deprecate QCoreApplication::flush()
... as it has outlived its original purpose: Qt3 implementation on X11: void QApplication::flush() { flushX(); } void QApplication::flushX() { if (appDpy) XFlush( appDpy ); } Qt4 implementation on X11: Did nothing when QApplication::flush() was called (the flush() overrides in {unix,glib} event dispatchers with empty bodies). In Qt5 this function somehow has been repurposed (inconsistently) to do what QCoreApplication::sendPostedEvents already does: QAbstractEventDispatcher::flush() = 0; => QCocoaEventDispatcher::flush() {} => QEventDispatcherCoreFoundation::flush() {} => QIOSEventDispatcher (does not override ::flush()) => QEventDispatcherGlib::flush() {} => QPAEventDispatcherGlib (does not override ::flush()) => QEventDispatcherUNIX::flush() {} => QUnixEventDispatcherQPA (when QT_NO_GLIB=true) ::flush() { if (qApp) qApp->sendPostedEvents(); }) ==> QAndroidEventDispatcher (does not override ::flush()) => QEventDispatcherWin32::flush() {} => QOffscreenEventDispatcher::flush() { if (qApp) qApp->sendPostedEvents(); QEventDispatcherWin32::flush(); } => QWindowsGuiEventDispatcher (does not override ::flush()) => QWindowsDirect2DEventDispatcher (does not override ::flush()) => QEventDispatcherWinRT::flush() {} => QOffscreenEventDispatcher::flush() { if (qApp) qApp->sendPostedEvents(); QEventDispatcherWinRT::flush(); } => QWinRTEventDispatcher (qminimaleglintegration.cpp) (does not override ::flush()) => QWinRTEventDispatcher (qwinrteventdispatcher.h) (does not override ::flush()) Whatever this function was doing on macOS in Qt3 and Qt4 also has been dropped in Qt5. It appears that the other event dispatchers in Qt5 that have overrides for flush() have simply copy-pasted this logic. Clearly the documentation of QCoreApplication::flush() is outdated and has nothing to do with the actual implementation in Qt5. This function is rarely used in Qt5 sources. It should be safe to remove the calls to QCoreApplication::flush() from Qt source code, as this function has been doing nothing on most platforms anyways. Repurposing it even broke handling of posted events (see QTBUG-48717). [ChangeLog][QtCore][Event loop] QCoreApplication::flush() is now deprecated. Use QCoreApplication::processEvents() and QCoreApplication::sendPostedEvents() instead. Task-number: QTBUG-33489 Task-number: QTBUG-48717 Change-Id: Icc7347ff203024b7153ea74be6bf527dd07ce821 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Gunnar Sletta <gunnar@crimson.no>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp18
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp19
2 files changed, 13 insertions, 24 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index c0bd8bce5a..77fb203b82 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -396,8 +396,7 @@ void QAbstractButtonPrivate::click()
}
blockRefresh = false;
refresh();
- q->repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ q->repaint();
if (guard)
emitReleased();
if (guard)
@@ -834,8 +833,7 @@ void QAbstractButton::animateClick(int msec)
if (d->checkable && focusPolicy() & Qt::ClickFocus)
setFocus();
setDown(true);
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
if (!d->animateTimer.isActive())
d->emitPressed();
d->animateTimer.start(msec, this);
@@ -977,8 +975,7 @@ void QAbstractButton::mousePressEvent(QMouseEvent *e)
if (hitButton(e->pos())) {
setDown(true);
d->pressed = true;
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
d->emitPressed();
e->accept();
} else {
@@ -1025,8 +1022,7 @@ void QAbstractButton::mouseMoveEvent(QMouseEvent *e)
if (hitButton(e->pos()) != d->down) {
setDown(!d->down);
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
if (d->down)
d->emitPressed();
else
@@ -1051,8 +1047,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
case Qt::Key_Space:
if (!e->isAutoRepeat()) {
setDown(true);
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
d->emitPressed();
}
break;
@@ -1103,8 +1098,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
#ifndef QT_NO_SHORTCUT
if (e->matches(QKeySequence::Cancel) && d->down) {
setDown(false);
- repaint(); //flush paint event before invoking potentially expensive operation
- QApplication::flush();
+ repaint();
d->emitReleased();
return;
}
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index 4ad2b83582..2758af53ef 100644
--- a/src/widgets/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
@@ -164,15 +164,14 @@ void QSplashScreen::mousePressEvent(QMouseEvent *)
}
/*!
- This overrides QWidget::repaint(). It differs from the standard
- repaint function in that it also calls QApplication::flush() to
- ensure the updates are displayed, even when there is no event loop
- present.
+ This overrides QWidget::repaint(). It differs from the standard repaint
+ function in that it also calls QApplication::processEvents() to ensure
+ the updates are displayed, even when there is no event loop present.
*/
void QSplashScreen::repaint()
{
QWidget::repaint();
- QApplication::flush();
+ QApplication::processEvents();
}
/*!
@@ -190,13 +189,9 @@ void QSplashScreen::repaint()
/*!
Draws the \a message text onto the splash screen with color \a
color and aligns the text according to the flags in \a alignment.
-
- To make sure the splash screen is repainted immediately, you can
- call \l{QCoreApplication}'s
- \l{QCoreApplication::}{processEvents()} after the call to
- showMessage(). You usually want this to make sure that the message
- is kept up to date with what your application is doing (e.g.,
- loading files).
+ This function calls repaint() to make sure the splash screen is
+ repainted immediately. As a result the message is kept up
+ to date with what your application is doing (e.g. loading files).
\sa Qt::Alignment, clearMessage(), message()
*/