[vlc-commits] qt: ensure that the QML view is destroyed before its context in DummyCompositor

Pierre Lamot git at videolan.org
Thu Oct 29 09:08:25 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Oct 16 17:12:49 2020 +0200| [75421e58fec21c9899fdc2a03dc431cd581af6c3] | committer: Pierre Lamot

qt: ensure that the QML view is destroyed before its context in DummyCompositor

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=75421e58fec21c9899fdc2a03dc431cd581af6c3
---

 modules/gui/qt/maininterface/compositor_dummy.cpp | 15 ++++++++++-----
 modules/gui/qt/maininterface/compositor_dummy.hpp |  3 ++-
 modules/gui/qt/medialibrary/mlbasemodel.cpp       |  1 +
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/gui/qt/maininterface/compositor_dummy.cpp b/modules/gui/qt/maininterface/compositor_dummy.cpp
index f972ac4790..59b88ab5c4 100644
--- a/modules/gui/qt/maininterface/compositor_dummy.cpp
+++ b/modules/gui/qt/maininterface/compositor_dummy.cpp
@@ -35,16 +35,16 @@ MainInterface* CompositorDummy::makeMainInterface()
     if (m_rootWindow->useClientSideDecoration())
         m_rootWindow->setWindowFlag(Qt::FramelessWindowHint);
     m_rootWindow->show();
-    QQuickWidget* centralWidget = new QQuickWidget(m_rootWindow);
-    centralWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
+    m_qmlWidget = new QQuickWidget(m_rootWindow);
+    m_qmlWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
 
     new InterfaceWindowHandler(m_intf, m_rootWindow, m_rootWindow->windowHandle(), m_rootWindow);
 
     MainUI* m_ui = new MainUI(m_intf, m_rootWindow, m_rootWindow->windowHandle(), this);
-    m_ui->setup(centralWidget->engine());
-    centralWidget->setContent(QUrl(), m_ui->getComponent(), m_ui->createRootItem());
+    m_ui->setup(m_qmlWidget->engine());
+    m_qmlWidget->setContent(QUrl(), m_ui->getComponent(), m_ui->createRootItem());
 
-    m_rootWindow->setCentralWidget(centralWidget);
+    m_rootWindow->setCentralWidget(m_qmlWidget);
 
     connect(m_rootWindow, &MainInterface::requestInterfaceMaximized,
             m_rootWindow, &MainInterface::showMaximized);
@@ -56,6 +56,11 @@ MainInterface* CompositorDummy::makeMainInterface()
 
 void CompositorDummy::destroyMainInterface()
 {
+    if (m_qmlWidget)
+    {
+        delete m_qmlWidget;
+        m_qmlWidget = nullptr;
+    }
     if (m_rootWindow)
     {
         delete m_rootWindow;
diff --git a/modules/gui/qt/maininterface/compositor_dummy.hpp b/modules/gui/qt/maininterface/compositor_dummy.hpp
index 51647d1ac0..207b6ea0e2 100644
--- a/modules/gui/qt/maininterface/compositor_dummy.hpp
+++ b/modules/gui/qt/maininterface/compositor_dummy.hpp
@@ -26,6 +26,7 @@
 #include "compositor.hpp"
 
 class MainInterface;
+class QQuickWidget;
 
 namespace vlc {
 
@@ -42,10 +43,10 @@ public:
     bool setupVoutWindow(vout_window_t *p_wnd) override;
 
 protected:
-
     intf_thread_t *m_intf;
 
     MainInterface* m_rootWindow = nullptr;
+    QQuickWidget* m_qmlWidget = nullptr;
 };
 
 }
diff --git a/modules/gui/qt/medialibrary/mlbasemodel.cpp b/modules/gui/qt/medialibrary/mlbasemodel.cpp
index 285397c0c9..6eb14530a7 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.cpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.cpp
@@ -136,6 +136,7 @@ MediaLib* MLBaseModel::ml() const
 
 void MLBaseModel::setMl(MediaLib* medialib)
 {
+    assert(medialib);
     m_ml = medialib->vlcMl();
     m_mediaLib = medialib;
     if ( m_ml_event_handle == nullptr )



More information about the vlc-commits mailing list