[vlc-commits] [Git][videolan/vlc][master] qt: fix MouseEventFilter crash on exit

Romain Vimont (@rom1v) gitlab at videolan.org
Fri Dec 17 17:09:39 UTC 2021



Romain Vimont pushed to branch master at VideoLAN / VLC


Commits:
793ffc25 by Romain Vimont at 2021-12-17T15:19:01+00:00
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 f1bda18e405b0bc69a7adf29fbdae2619f739ad5
Refs 53ec7adcb9a7f4cc5458782ae32ce9aef635b7f8
Fixes #26325

- - - - -


1 changed file:

- modules/gui/qt/util/mouse_event_filter.hpp


Changes:

=====================================
modules/gui/qt/util/mouse_event_filter.hpp
=====================================
@@ -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;
 };



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/793ffc25048f5df06b7d2bf88ddca2aee1503876

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/793ffc25048f5df06b7d2bf88ddca2aee1503876
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list