From 809fc41c9b19388a21ee8e23601156579780cda3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 8 Jun 2011 15:49:33 +0200 Subject: Protect against deleted windows Check that the window is still there before trying to deliver an event to it. Reviewed-by: Samuel --- src/gui/kernel/qapplication_qpa.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index 98359e4..5787c71 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -612,6 +612,9 @@ void QApplication::setMainWidget(QWidget *mainWidget) void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e) { + if (!e->widget) + return; + // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); static QWeakPointer implicit_mouse_grabber; @@ -768,6 +771,10 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e) { + + if (!e->widget) + return; + // QPoint localPoint = ev.pos(); QPoint globalPoint = e->globalPos; // bool trustLocalPoint = !!tlw; //is there something the local point can be local to? @@ -842,12 +849,18 @@ void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEven void QApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e) { + if (!e->enter) + return; + QApplicationPrivate::dispatchEnterLeave(e->enter.data(),0); qt_last_mouse_receiver = e->enter.data(); } void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e) { + if (!e->leave) + return; + QApplicationPrivate::dispatchEnterLeave(0,qt_last_mouse_receiver); if (e->leave.data() && !e->leave.data()->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen @@ -858,6 +871,9 @@ void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Leave void QApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e) { + if (!e->activated) + return; + QApplication::setActiveWindow(e->activated.data()); } -- cgit v0.12