Avoid dangling d-pointer deref in QWidgetWindow::handleMouseEvent
If you drag-and-drop a OpenGLWidget in Designer, the main window gets re-created when the OpenGLWidget is instantiated. So in general (in rare cases), at the end of QWidgetWindow::handleMouseEvent() we might have a different window, and therefore can't reliably call QWindowPrivate::maybeSynthesizeContextMenuEvent() without checking for a valid pointer. Amends 84a5f50c7766c99f62b22bb4388137e0aa8dd13d Fixes: QTBUG-132912 Change-Id: I7b220b4daceab988aadabf9427ef6b2d5624e00d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 1accd2421686b387daa115b3a46974fce0fdb118) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
cfe906856b
commit
3bcc785d0c
@ -506,6 +506,11 @@ void QWidgetWindow::handleNonClientAreaMouseEvent(QMouseEvent *e)
|
||||
void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_D(QWidgetWindow);
|
||||
|
||||
// Event delivery can potentially result in window re-creation (QTBUG-132912)
|
||||
// so we need QPointer to avoid a dangling d below
|
||||
QPointer<QWidgetWindow> self = this;
|
||||
|
||||
if (auto *activePopupWidget = QApplication::activePopupWidget()) {
|
||||
QPointF mapped = event->position();
|
||||
if (activePopupWidget != m_widget)
|
||||
@ -666,6 +671,9 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
|
||||
event->setAccepted(translated.isAccepted());
|
||||
}
|
||||
|
||||
if (self.isNull())
|
||||
return;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
|
||||
if (
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user