summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidgetwindow.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-04-04 09:44:07 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-04 10:46:21 +0200
commitba2ea6da298bfd234af1afeaf154fa4aaefaad88 (patch)
tree083ccb2350a907e7669d137f0052bab8fb5c47f2 /src/widgets/kernel/qwidgetwindow.cpp
parent11b8794456e4abb5c2068bb1ee1067fcdf79baa1 (diff)
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 <laszlo.agocs@digia.com>
Diffstat (limited to 'src/widgets/kernel/qwidgetwindow.cpp')
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp12
1 files 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<QWidget> 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