summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qt_cocoa_helpers_mac.mm
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2010-02-15 12:33:07 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2010-02-23 12:37:10 (GMT)
commit526c6fd4686a8e87e5087ebcac941405f742304a (patch)
treecb16c07e1db7908e73019092705ca8543c19a566 /src/gui/kernel/qt_cocoa_helpers_mac.mm
parentde4332a4728e739b37e9c7b04c021e150e096270 (diff)
downloadQt-526c6fd4686a8e87e5087ebcac941405f742304a.zip
Qt-526c6fd4686a8e87e5087ebcac941405f742304a.tar.gz
Qt-526c6fd4686a8e87e5087ebcac941405f742304a.tar.bz2
Prevent stale QWidget pointers in QCocoaView
QCocoaView has two "back" pointers ot its owning QWidget and the corresponding QWidgetPrivate. The lifetime of the QCocoaView might be longer and that of the QWidget if Cocoa itself holds references to it. In addition accessing a QWidget that is being destroyed is not safe. Set both pack pointers to NULL in ~QWidget. This prevents following stale pointers in the QCocoaView callbacks. This also means that we'll see the NULL pointers, add gurads for that.
Diffstat (limited to 'src/gui/kernel/qt_cocoa_helpers_mac.mm')
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index e9fdbda..9560952 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -369,6 +369,16 @@ QMacTabletHash *qt_mac_tablet_hash()
}
#ifdef QT_MAC_USE_COCOA
+
+// Clears the QWidget pointer that each QCocoaView holds.
+void qt_mac_clearCocoaViewQWidgetPointers(QWidget *widget)
+{
+ QCocoaView *cocoaView = reinterpret_cast<QCocoaView *>(qt_mac_nativeview_for(widget));
+ if (cocoaView && [cocoaView respondsToSelector:@selector(qt_qwidget)]) {
+ [cocoaView qt_clearQWidget];
+ }
+}
+
void qt_dispatchTabletProximityEvent(void * /*NSEvent * */ tabletEvent)
{
NSEvent *proximityEvent = static_cast<NSEvent *>(tabletEvent);