Skip to content
Snippets Groups Projects
Commit 793ffc25 authored by Romain Vimont's avatar Romain Vimont Committed by Romain Vimont
Browse files

qt: fix MouseEventFilter crash on exit

The target QObject may be destroyed before the MouseEventFilter
instance, causing a crash in MouseEventFilter::detach():

    /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h:524:12: runtime error: downcast of address 0x60f000114580 which does not point to an object of type 'QQuickItem'
    0x60f000114580: note: object is of type 'QObject'
     09 00 00 00  e0 8e ff 16 af 7f 00 00  80 a8 0c 00 a0 61 00 00  78 e8 97 18 af 7f 00 00  00 00 00 00
                  ^~~~~~~~~~~~~~~~~~~~~~~
                  vptr for 'QObject'
    ../../modules/gui/qt/util/mouse_event_filter.cpp:122:42: runtime error: member call on address 0x60f000114580 which does not point to an object of type 'QQuickItem'
    0x60f000114580: note: object is of type 'QObject'
     09 00 00 00  e0 8e ff 16 af 7f 00 00  80 a8 0c 00 a0 61 00 00  78 e8 97 18 af 7f 00 00  00 00 00 00
                  ^~~~~~~~~~~~~~~~~~~~~~~
                  vptr for 'QObject'

Use a QPointer to reset the target to nullptr when the QObject is
destroyed, to avoid a use-after-free in detach().

Refs f1bda18e
Refs 53ec7adc
Fixes #26325
parent 1d25803a
Branches native_menus
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
#include <QObject>
#include <QPointF>
#include <QPointer>
class MouseEventFilter : public QObject
{
......@@ -51,7 +52,7 @@ private:
void detach();
private:
QObject *m_target = nullptr;
QPointer<QObject> m_target;
Qt::MouseButtons m_targetItemInitialAcceptedMouseButtons = 0;
bool m_filterEventsSynthesizedByQt = false;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment