Restore the QEvent::d pointer to null after we're done using it
authorThiago Macieira <thiago.macieira@intel.com>
Mon, 14 May 2012 12:10:45 +0000 (14:10 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 15 May 2012 18:44:36 +0000 (20:44 +0200)
Change-Id: I2fd6ebd80bf47456d74e939d49bff4ac9f199e8b
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
src/widgets/graphicsview/qgraphicsview.cpp

index 3629341..17212ba 100644 (file)
@@ -271,6 +271,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
 #include <QtCore/qdatetime.h>
 #include <QtCore/qdebug.h>
 #include <QtCore/qmath.h>
+#include <QtCore/qscopedvaluerollback.h>
 #include <QtWidgets/qapplication.h>
 #include <QtWidgets/qdesktopwidget.h>
 #include <QtGui/qevent.h>
@@ -2777,7 +2778,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
             QApplication::sendEvent(d->scene, &windowDeactivate);
         }
         break;
-    case QEvent::Leave:
+    case QEvent::Leave: {
         // ### This is a temporary fix for until we get proper mouse grab
         // events. activeMouseGrabberItem should be set to 0 if we lose the
         // mouse grab.
@@ -2790,9 +2791,11 @@ bool QGraphicsView::viewportEvent(QEvent *event)
         d->useLastMouseEvent = false;
         // a hack to pass a viewport pointer to the scene inside the leave event
         Q_ASSERT(event->d == 0);
+        QScopedValueRollback<QEventPrivate *> rb(event->d);
         event->d = reinterpret_cast<QEventPrivate *>(viewport());
         QApplication::sendEvent(d->scene, event);
         break;
+    }
 #ifndef QT_NO_TOOLTIP
     case QEvent::ToolTip: {
         QHelpEvent *toolTip = static_cast<QHelpEvent *>(event);