summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-04-15 16:06:33 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-04-16 11:18:03 (GMT)
commitd22afdb8cf874aae3c5593f6108d4c7897a8ac20 (patch)
treed132ca68e5c7510723ba1b76b43d67b26dc31d43 /src/gui
parentbefbaa0c61876c3bfebe29499fd16930db400b2b (diff)
downloadQt-d22afdb8cf874aae3c5593f6108d4c7897a8ac20.zip
Qt-d22afdb8cf874aae3c5593f6108d4c7897a8ac20.tar.gz
Qt-d22afdb8cf874aae3c5593f6108d4c7897a8ac20.tar.bz2
Mac: Graphics View starving user events and sometimes crashes.
Problem was that we called processEvents() and excluded user input events. The idea was to only process pending update requests, but by doing that there's also a chance that user input events will starve. Also, there's no gurantee that only update requests will be processed by processEvents(), so a safer solution is to call "HIViewRender" on Carbon and "displayIfNeeded" on Cocoa. This will for sure dispatch pending update requests and nothing else (which is exactly what we want). No auto test regressions. Fixes tst_qgraphicsproxywidget::updateAndDelete failure on Carbon. Benchmarks indicate an increase in performance. Task-number: QTBUG-7502 Reviewed-by: richard
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h8
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm11
2 files changed, 17 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h
index 9d3edcb..1c66d07 100644
--- a/src/gui/graphicsview/qgraphicsview_p.h
+++ b/src/gui/graphicsview/qgraphicsview_p.h
@@ -183,8 +183,12 @@ public:
else
QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
#else
- QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::ExcludeSocketNotifiers
- | QEventLoop::ExcludeUserInputEvents);
+ // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa)
+ // is called, which means there's a pending update request. We want to dispatch it
+ // now because otherwise graphics view updates would require two
+ // round-trips in the event loop before the item is painted.
+ extern void qt_mac_dispatchPendingUpdateRequests(QWidget *);
+ qt_mac_dispatchPendingUpdateRequests(viewport->window());
#endif
}
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 65c04e5..ce1e3c5 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -1167,6 +1167,17 @@ CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
return context;
}
+void qt_mac_dispatchPendingUpdateRequests(QWidget *widget)
+{
+ if (!widget)
+ return;
+#ifndef QT_MAC_USE_COCOA
+ HIViewRender(qt_mac_nativeview_for(widget));
+#else
+ [qt_mac_nativeview_for(widget) displayIfNeeded];
+#endif
+}
+
CGFloat qt_mac_get_scalefactor()
{
#ifndef QT_MAC_USE_COCOA