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>
This commit is contained in:
parent
11b8794456
commit
ba2ea6da29
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user