From ba2ea6da298bfd234af1afeaf154fa4aaefaad88 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 4 Apr 2014 09:44:07 +0200 Subject: Don't assume qt_tablet_target widget exists from one event to the next In this scenario there is a widget with a button inside, and you click the button with the tablet. The target of the event is the button, but when you click it, the parent (or ancestor) is destroyed. Commit 2bac49265efcf8faabc3756d1a3e405a3d336f68 took care of the case when the parent is a window, but it is not always a window which is being destroyed. So the approach of using a QPointer is better because it should take care of all the cases when the qt_tablet_target is destroyed during the course of a tablet event sequence. Task-number: QTBUG-36848 Task-number: QTBUG-38040 Change-Id: Ia0e861f2cb2fbc30234aa596f3a36ddd0835a9af Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qwidgetwindow.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 41a3dcc048..0031d8e965 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -58,8 +58,7 @@ QT_BEGIN_NAMESPACE Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets(); QWidget *qt_button_down = 0; // widget got last button-down -static QWidget *qt_tablet_target = 0; -static QWidget *qt_tablet_target_window = 0; +static QPointer qt_tablet_target = 0; // popup control QWidget *qt_popup_down = 0; // popup that contains the pressed widget @@ -105,10 +104,6 @@ QWidgetWindow::QWidgetWindow(QWidget *widget) QWidgetWindow::~QWidgetWindow() { - if (m_widget == qt_tablet_target_window) { - qt_tablet_target = 0; - qt_tablet_target_window = 0; - } } #ifndef QT_NO_ACCESSIBILITY @@ -791,7 +786,6 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event) widget = m_widget; qt_tablet_target = widget; - qt_tablet_target_window = m_widget; } if (qt_tablet_target) { @@ -804,10 +798,8 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event) QGuiApplication::sendSpontaneousEvent(qt_tablet_target, &ev); } - if (event->type() == QEvent::TabletRelease) { + if (event->type() == QEvent::TabletRelease) qt_tablet_target = 0; - qt_tablet_target_window = 0; - } } #endif // QT_NO_TABLETEVENT -- cgit v1.2.3