[vlc-commits] [Git][videolan/vlc][master] qt: delete explicitly the InterfaceWindowHandler before destroying the interface

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Sun Aug 22 11:55:06 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
71c7f79d by Pierre Lamot at 2021-08-22T11:44:36+00:00
qt: delete explicitly the InterfaceWindowHandler before destroying the interface

 using Qt parenting auto deletion leads to using the window in
 InterfaceWindowHandler destructor while it's partially destroyed

- - - - -


6 changed files:

- modules/gui/qt/maininterface/compositor_dcomp.cpp
- modules/gui/qt/maininterface/compositor_dcomp.hpp
- modules/gui/qt/maininterface/compositor_dummy.cpp
- modules/gui/qt/maininterface/compositor_dummy.hpp
- modules/gui/qt/maininterface/compositor_win7.cpp
- modules/gui/qt/maininterface/compositor_win7.hpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor_dcomp.cpp
=====================================
@@ -317,14 +317,14 @@ MainInterface* CompositorDirectComposition::makeMainInterface()
 
         //install the interface window handler after the creation of CompositorDCompositionUISurface
         //so the event filter is handled before the one of the UISurface (for wheel events)
-        m_interfaceWindowHandler = new InterfaceWindowHandlerWin32(m_intf, m_mainInterface, m_rootWindow, m_rootWindow);
+        m_interfaceWindowHandler = std::make_unique<InterfaceWindowHandlerWin32>(m_intf, m_mainInterface, m_rootWindow);
 
         m_qmlVideoSurfaceProvider = std::make_unique<VideoSurfaceProvider>();
         m_mainInterface->setVideoSurfaceProvider(m_qmlVideoSurfaceProvider.get());
         m_mainInterface->setCanShowVideoPIP(true);
 
         connect(m_qmlVideoSurfaceProvider.get(), &VideoSurfaceProvider::hasVideoEmbedChanged,
-                m_interfaceWindowHandler, &InterfaceWindowHandlerWin32::onVideoEmbedChanged);
+                m_interfaceWindowHandler.get(), &InterfaceWindowHandlerWin32::onVideoEmbedChanged);
         connect(m_qmlVideoSurfaceProvider.get(), &VideoSurfaceProvider::surfacePositionChanged,
                 this, &CompositorDirectComposition::onSurfacePositionChanged);
 
@@ -383,6 +383,7 @@ void CompositorDirectComposition::unloadGUI()
     m_uiSurface.reset();
     m_ui.reset();
     m_taskbarWidget.reset();
+    m_interfaceWindowHandler.reset();
     if (m_mainInterface)
     {
         delete m_mainInterface;


=====================================
modules/gui/qt/maininterface/compositor_dcomp.hpp
=====================================
@@ -81,7 +81,7 @@ private:
     std::unique_ptr<MainUI> m_ui;
     std::unique_ptr<VideoWindowHandler> m_videoWindowHandler;
     std::unique_ptr<VideoSurfaceProvider> m_qmlVideoSurfaceProvider;
-    InterfaceWindowHandler* m_interfaceWindowHandler = nullptr;
+    std::unique_ptr<InterfaceWindowHandler> m_interfaceWindowHandler;
 
     //main window composition
     HINSTANCE m_dcomp_dll = nullptr;


=====================================
modules/gui/qt/maininterface/compositor_dummy.cpp
=====================================
@@ -54,7 +54,7 @@ MainInterface* CompositorDummy::makeMainInterface()
         m_qmlWidget->setFlag(Qt::FramelessWindowHint);
     m_qmlWidget->setResizeMode(QQuickView::SizeRootObjectToView);
 
-    new InterfaceWindowHandler(m_intf, m_mainInterface.get(), m_qmlWidget.get(), m_qmlWidget.get());
+    m_intfWindowHandler = std::make_unique<InterfaceWindowHandler>(m_intf, m_mainInterface.get(), m_qmlWidget.get());
 
     MainUI* ui = new MainUI(m_intf, m_mainInterface.get(), m_qmlWidget.get(), m_qmlWidget.get());
     ui->setup(m_qmlWidget->engine());
@@ -77,6 +77,7 @@ void CompositorDummy::destroyMainInterface()
 
 void CompositorDummy::unloadGUI()
 {
+    m_intfWindowHandler.reset();
     m_qmlWidget.reset();
     m_mainInterface.reset();
 }


=====================================
modules/gui/qt/maininterface/compositor_dummy.hpp
=====================================
@@ -27,6 +27,7 @@
 
 class MainInterface;
 class QQuickView;
+class InterfaceWindowHandler;
 
 namespace vlc {
 
@@ -63,6 +64,7 @@ public:
 protected:
     qt_intf_t *m_intf;
 
+    std::unique_ptr<InterfaceWindowHandler> m_intfWindowHandler;
     std::unique_ptr<MainInterface> m_mainInterface;
     std::unique_ptr<QQuickView> m_qmlWidget;
 };


=====================================
modules/gui/qt/maininterface/compositor_win7.cpp
=====================================
@@ -198,7 +198,7 @@ MainInterface* CompositorWin7::makeMainInterface()
     m_videoWindowHandler = std::make_unique<VideoWindowHandler>(m_intf, m_mainInterface);
     m_videoWindowHandler->setWindow( m_qmlView.get() );
 
-    new InterfaceWindowHandlerWin32(m_intf, m_mainInterface, m_qmlView.get(), m_qmlView.get());
+    m_interfaceWindowHandler = std::make_unique<InterfaceWindowHandlerWin32>(m_intf, m_mainInterface, m_qmlView.get());
 
     m_taskbarWidget = std::make_unique<WinTaskbarWidget>(m_intf, m_qmlView.get());
     qApp->installNativeEventFilter(m_taskbarWidget.get());
@@ -226,6 +226,7 @@ void CompositorWin7::unloadGUI()
 {
     m_videoSurfaceProvider.reset();
     m_videoWindowHandler.reset();
+    m_interfaceWindowHandler.reset();
     m_qmlView.reset();
     m_taskbarWidget.reset();
     if (m_mainInterface)


=====================================
modules/gui/qt/maininterface/compositor_win7.hpp
=====================================
@@ -25,6 +25,7 @@
 #include <memory>
 
 class WinTaskbarWidget;
+class InterfaceWindowHandlerWin32;
 
 namespace vlc {
 
@@ -80,6 +81,7 @@ private:
     MainInterface* m_mainInterface = nullptr;
     QWidget* m_videoWidget = nullptr;
     QWidget* m_stable = nullptr;
+    std::unique_ptr<InterfaceWindowHandlerWin32> m_interfaceWindowHandler;
     std::unique_ptr<QQuickView> m_qmlView;
     std::unique_ptr<VideoWindowHandler> m_videoWindowHandler;
     std::unique_ptr<VideoSurfaceProvider> m_videoSurfaceProvider;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/71c7f79d60ae5aa9a51ed7d823752ddad3d4aee5

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




More information about the vlc-commits mailing list