[vlc-devel] [PATCH 3/3] qt: fix release order of QML components when using DirectComposition

Pierre Lamot pierre at videolabs.io
Wed May 20 18:20:23 CEST 2020


  Deleting QmlEngine before QML root item caused context property to be released
  too early as they were attached to the QML engine
---
 .../maininterface/compositor_dcomp_uisurface.cpp   |  4 ++--
 modules/gui/qt/maininterface/mainui.cpp            | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/modules/gui/qt/maininterface/compositor_dcomp_uisurface.cpp b/modules/gui/qt/maininterface/compositor_dcomp_uisurface.cpp
index 173f38bea7..e973e17420 100644
--- a/modules/gui/qt/maininterface/compositor_dcomp_uisurface.cpp
+++ b/modules/gui/qt/maininterface/compositor_dcomp_uisurface.cpp
@@ -229,10 +229,10 @@ CompositorDCompositionUISurface::~CompositorDCompositionUISurface()
         delete m_uiOffscreenSurface;
     if (m_context)
         delete m_context;
-    if (m_qmlEngine)
-        delete m_qmlEngine;
     if (m_rootItem)
         delete m_rootItem;
+    if (m_qmlEngine)
+        delete m_qmlEngine;
     releaseSharedTexture();
 }
 
diff --git a/modules/gui/qt/maininterface/mainui.cpp b/modules/gui/qt/maininterface/mainui.cpp
index 2b1c44ce38..4671e6f216 100644
--- a/modules/gui/qt/maininterface/mainui.cpp
+++ b/modules/gui/qt/maininterface/mainui.cpp
@@ -104,19 +104,19 @@ bool MainUI::setup(QQmlEngine* engine)
 
     QQmlContext *rootCtx = engine->rootContext();
 
-    rootCtx->setContextProperty( "history", new NavigationHistory(engine) );
+    rootCtx->setContextProperty( "history", new NavigationHistory(this) );
     rootCtx->setContextProperty( "player", m_intf->p_sys->p_mainPlayerController );
-    rootCtx->setContextProperty( "i18n", new I18n(engine) );
-    rootCtx->setContextProperty( "mainctx", new QmlMainContext(m_intf, m_mainInterface, engine));
+    rootCtx->setContextProperty( "i18n", new I18n(this) );
+    rootCtx->setContextProperty( "mainctx", new QmlMainContext(m_intf, m_mainInterface, this));
     rootCtx->setContextProperty( "mainInterface", m_mainInterface);
     rootCtx->setContextProperty( "topWindow", m_mainInterface->windowHandle());
     rootCtx->setContextProperty( "dialogProvider", DialogsProvider::getInstance());
-    rootCtx->setContextProperty( "recentsMedias",  new VLCRecentMediaModel( m_intf, engine ));
-    rootCtx->setContextProperty( "settings",  new Settings( m_intf, engine ));
-    rootCtx->setContextProperty( "systemPalette", new SystemPalette(engine));
+    rootCtx->setContextProperty( "recentsMedias",  new VLCRecentMediaModel( m_intf, this ));
+    rootCtx->setContextProperty( "settings",  new Settings( m_intf, this ));
+    rootCtx->setContextProperty( "systemPalette", new SystemPalette(this));
 
     if (m_hasMedialibrary)
-        rootCtx->setContextProperty( "medialib", new MediaLib(m_intf, engine) );
+        rootCtx->setContextProperty( "medialib", new MediaLib(m_intf, this) );
     else
         rootCtx->setContextProperty( "medialib", nullptr );
 
-- 
2.25.1



More information about the vlc-devel mailing list