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 <laszlo.agocs@digia.com>bb10
parent
04ef22b9ee
commit
2bac49265e
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue