summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-05-10 12:09:40 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-05-10 12:09:40 +0200
commitd1622207ba501b93bd83b88d61a5631d3d0da0cc (patch)
tree64b50fb5b17257e3f7482d8041fc2a9befde43c9 /src
parent5dc3a46a2ac56321a888ada4c15d95cabd3a4159 (diff)
Prevent crash in QWidgetWindow::handleMouseEvent().
Don't use mapFrom() between widgets not in the same hierarchy.
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp
index d1ef77d48c..e8b1a6d096 100644
--- a/src/widgets/kernel/qwidgetwindow_qpa.cpp
+++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp
@@ -112,10 +112,19 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
{
// which child should have it?
- QWidget *widget = m_implicit_mouse_grabber ? m_implicit_mouse_grabber.data() : m_widget->childAt(event->pos());
+ QPoint mapped = event->pos();
+ QWidget *widget = 0;
+
+ if (m_implicit_mouse_grabber) {
+ widget = m_implicit_mouse_grabber.data();
+ mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos()));
+ } else if ((widget = m_widget->childAt(event->pos()))) {
+ mapped = widget->mapFrom(m_widget, event->pos());
+ }
if (qApp->d_func()->inPopupMode()) {
widget = qApp->activePopupWidget();
+ mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos()));
m_implicit_mouse_grabber.clear();
}
@@ -128,8 +137,6 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (event->buttons() == Qt::NoButton)
m_implicit_mouse_grabber.clear();
- QPoint mapped = widget->mapFrom(m_widget, event->pos());
-
if (widget != qt_last_mouse_receiver) {
QApplicationPrivate::dispatchEnterLeave(widget, qt_last_mouse_receiver);
qt_last_mouse_receiver = widget;