qtquick: Fix crash when mouse receiver gets deleted

Happened when double clicking a tab
This commit is contained in:
Sergio Martins
2022-10-07 05:43:11 +01:00
parent 04c069bf1b
commit 8adba89a83
2 changed files with 10 additions and 0 deletions

View File

@@ -126,6 +126,9 @@ bool TabBar_qtquick::event(QEvent *ev)
m_tabBar->onMousePress(me->pos());
else
m_tabBar->onMouseDoubleClick(me->pos());
// Don't call base class, it might have been deleted
return true;
}
break;

View File

@@ -80,7 +80,14 @@ public:
// Finally send the event
m_eventTarget->setProperty("cursorPosition", m_eventSource->property("cursorPosition"));
QPointer<QObject> lifeGuard(this);
qGuiApp->sendEvent(m_eventTarget, me);
if (!lifeGuard) {
// m_eventTarget was deleted, and so was "this"
return true;
}
m_eventTarget->setProperty("cursorPosition", CursorPosition_Undefined);
return false;