[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: update ownership of the acrylic effect in DComp compositor

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Mon Oct 28 05:10:43 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
c9d44d69 by Pierre Lamot at 2024-10-28T04:58:41+00:00
qt: update ownership of the acrylic effect in DComp compositor

The CompositorDCompositionAcrylicSurface is owned and only used inside
CompositorDComp, there is no need for QPointer here

- - - - -
61f3e38a by Pierre Lamot at 2024-10-28T04:58:41+00:00
qt: reset MainCtx pointer in compositor gui is unloaded

MainCtx shouldn't be accessed by the compositor after this point

- - - - -
37607671 by Pierre Lamot at 2024-10-28T04:58:41+00:00
qt: destroy MainCtx when UI is unloaded

MainCtx references some VLC interface variables, so it needs to be destroyed
before the interface is released. compositor shouln't use MainCtx once the UI is unloaded

fix: #28835

- - - - -


4 changed files:

- modules/gui/qt/maininterface/compositor.cpp
- modules/gui/qt/maininterface/compositor_dcomp.cpp
- modules/gui/qt/maininterface/compositor_dcomp.hpp
- modules/gui/qt/qt.cpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor.cpp
=====================================
@@ -333,6 +333,7 @@ void CompositorVideo::commonGUIDestroy()
     m_taskbarWidget.reset();
 #endif
     m_interfaceWindowHandler.reset();
+    m_mainCtx = nullptr;
 }
 
 void CompositorVideo::commonIntfDestroy()


=====================================
modules/gui/qt/maininterface/compositor_dcomp.cpp
=====================================
@@ -106,6 +106,8 @@ CompositorDirectComposition::CompositorDirectComposition( qt_intf_t* p_intf,  QO
 
 CompositorDirectComposition::~CompositorDirectComposition()
 {
+    //m_acrylicSurface should be released before the RHI context is destroyed
+    assert(!m_acrylicSurface);
     destroyMainInterface();
 }
 
@@ -219,13 +221,12 @@ void CompositorDirectComposition::setup()
         {
             try
             {
-                m_acrylicSurface = new CompositorDCompositionAcrylicSurface(m_intf, this, m_mainCtx, m_dcompDevice);
+                m_acrylicSurface = std::make_unique<CompositorDCompositionAcrylicSurface>(m_intf, this, m_mainCtx, m_dcompDevice);
             }
             catch (const std::exception& exception)
             {
                 if (const auto what = exception.what())
                     msg_Warn(m_intf, "%s", what);
-                delete m_acrylicSurface.data();
             }
         }
     }
@@ -303,6 +304,7 @@ void CompositorDirectComposition::destroyMainInterface()
 
 void CompositorDirectComposition::unloadGUI()
 {
+    m_acrylicSurface.reset();
     m_interfaceWindowHandler.reset();
     m_quickView.reset();
     commonGUIDestroy();
@@ -393,7 +395,7 @@ bool CompositorDirectComposition::eventFilter(QObject *watched, QEvent *event)
             static_cast<QPlatformSurfaceEvent *>(event)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed)
         {
             m_videoVisual.Reset();
-            delete m_acrylicSurface.data();
+            m_acrylicSurface.reset();
             // Just in case root visual deletes its children
             // when it is deleted: (Qt's UI visual should be
             // deleted by Qt itself)


=====================================
modules/gui/qt/maininterface/compositor_dcomp.hpp
=====================================
@@ -34,7 +34,6 @@
 
 class MainCtx;
 class WinTaskbarWidget;
-
 class QQuickView;
 
 class IDCompositionVisual;
@@ -43,6 +42,8 @@ class IDCompositionTarget;
 
 namespace vlc {
 
+class CompositorDCompositionAcrylicSurface;
+
 class CompositorDirectComposition : public CompositorVideo
 {
     Q_OBJECT
@@ -96,7 +97,7 @@ private:
     Microsoft::WRL::ComPtr<IDCompositionVisual> m_videoVisual;
     IDCompositionVisual *m_uiVisual = nullptr;
 
-    QPointer<class CompositorDCompositionAcrylicSurface> m_acrylicSurface;
+    std::unique_ptr<CompositorDCompositionAcrylicSurface> m_acrylicSurface;
 };
 
 }


=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -1145,17 +1145,18 @@ static void *ThreadCleanup( qt_intf_t *p_intf, CleanupReason cleanupReason )
     VLCDialogModel::killInstance();
     DialogErrorModel::killInstance();
 
+    //destroy MainCtx, Compositor shouldn't not use MainCtx after `unloadGUI`
+    if (p_intf->p_mi) {
+        delete p_intf->p_mi;
+        p_intf->p_mi = nullptr;
+    }
+
     if ( p_intf->p_compositor &&  cleanupReason == CLEANUP_APP_TERMINATED)
     {
         p_intf->p_compositor.reset();
 
-        //destroy MainCtx
-        delete p_intf->p_mi;
-        p_intf->p_mi = nullptr;
-
         delete p_intf->mainSettings;
         p_intf->mainSettings = nullptr;
-
     }
 
     /* Destroy the main playlist controller */



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/df08ba7c55cf6f85f479285ffbc37fcbd6bd77a0...37607671d463ec702940a864f9cdd628de1c6df8

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/df08ba7c55cf6f85f479285ffbc37fcbd6bd77a0...37607671d463ec702940a864f9cdd628de1c6df8
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list