From 2bac49265efcf8faabc3756d1a3e405a3d336f68 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 5 Mar 2014 10:32:59 +0100 Subject: Tablet target widget isn't always the same as its widget window In this scenario there is a widget with a QPushButton inside, and you click the pushbutton with the tablet. The target of the event is the pushbutton, but when you click it, the window is destroyed. The widgetwindow destructor cannot check the pushbutton's window() because it has already been destroyed. So it seems we have to store both widgets: the actual target and the parent widget which has the window. Task-number: QTBUG-36848 Change-Id: I37d8fb03743f3e501d695342edc42de104777b18 Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qwidgetwindow.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 3cc48b442d..e50736d6b8 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -59,6 +59,7 @@ 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; // popup control QWidget *qt_popup_down = 0; // popup that contains the pressed widget @@ -103,8 +104,10 @@ QWidgetWindow::QWidgetWindow(QWidget *widget) QWidgetWindow::~QWidgetWindow() { - if (m_widget == qt_tablet_target) + if (m_widget == qt_tablet_target_window) { qt_tablet_target = 0; + qt_tablet_target_window = 0; + } } #ifndef QT_NO_ACCESSIBILITY @@ -774,6 +777,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event) widget = m_widget; qt_tablet_target = widget; + qt_tablet_target_window = m_widget; } if (qt_tablet_target) { @@ -786,8 +790,10 @@ 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