[vlc-devel] [PATCH 1/3] qt: ensure that the QML view is destroyed before its context in DummyCompositor

Jean-Baptiste Kempf jb at videolan.org
Thu Oct 22 14:53:55 CEST 2020


Set LGTM.

On Thu, 22 Oct 2020, at 14:33, Pierre Lamot wrote:
> ---
>  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 )
> -- 
> 2.25.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734


More information about the vlc-devel mailing list