[vlc-commits] [Git][videolan/vlc][master] qt: FirstRun dialog must be destroyed before closing the application

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Sep 10 10:50:57 UTC 2021



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


Commits:
ac3b5978 by Pierre Lamot at 2021-09-10T09:55:36+00:00
qt: FirstRun dialog must be destroyed before closing the application

FirstRun dialog used Qt::WA_DeleteOnClose, it lifecycle would be bound to the
QApplication. On close the firstrun dialog will save some changes to the
preferences. So we need to ensure the dialog is properly destroyed before the
context becomes invalid when closing the application.

this commit updates 3895e912bffaed9f99a5f657272f307f2251791d which got reverted
in a39d17557548830bc00df44ba7b71a778ddd5853

- - - - -


5 changed files:

- modules/gui/qt/dialogs/dialogs_provider.cpp
- modules/gui/qt/dialogs/dialogs_provider.hpp
- modules/gui/qt/dialogs/firstrun/firstrunwizard.cpp
- modules/gui/qt/dialogs/firstrun/firstrunwizard.hpp
- modules/gui/qt/maininterface/main_interface.cpp


Changes:

=====================================
modules/gui/qt/dialogs/dialogs_provider.cpp
=====================================
@@ -54,6 +54,7 @@
 #include "dialogs/epg/epg.hpp"
 #include "dialogs/errors/errors.hpp"
 #include "dialogs/playlists/playlists.hpp"
+#include "dialogs/firstrun/firstrunwizard.hpp"
 
 #include <QEvent>
 #include <QApplication>
@@ -98,6 +99,7 @@ DialogsProvider::~DialogsProvider()
     PodcastConfigDialog::killInstance();
     OpenDialog::killInstance();
     ErrorsDialog::killInstance();
+    FirstRunWizard::killInstance();
 
     delete popupMenu;
     delete videoPopupMenu;
@@ -262,6 +264,13 @@ void DialogsProvider::prefsDialog()
     p->toggleVisible();
 }
 
+void DialogsProvider::firstRunDialog()
+{
+    FirstRunWizard *p = FirstRunWizard::getInstance( p_intf );
+    QVLCDialog::setWindowTransientParent(p, nullptr, p_intf);
+    p->show();
+}
+
 void DialogsProvider::extendedDialog()
 {
     ExtendedDialog *extDialog = ExtendedDialog::getInstance(p_intf );


=====================================
modules/gui/qt/dialogs/dialogs_provider.hpp
=====================================
@@ -136,6 +136,7 @@ public slots:
     void mediaInfoDialog( const PlaylistItem& pItem );
     void mediaCodecDialog();
     void prefsDialog();
+    void firstRunDialog();
     void extendedDialog();
     void synchroDialog();
     void messagesDialog();


=====================================
modules/gui/qt/dialogs/firstrun/firstrunwizard.cpp
=====================================
@@ -38,7 +38,6 @@ FirstRunWizard::FirstRunWizard( qt_intf_t *_p_intf, QWidget *parent)
     /* Set windown properties */
     setWindowTitle( qtr( "Welcome" ) );
     setWindowModality( Qt::WindowModal );
-    setAttribute( Qt::WA_DeleteOnClose );
 
     /* Build the Ui */
     ui.setupUi( this );


=====================================
modules/gui/qt/dialogs/firstrun/firstrunwizard.hpp
=====================================
@@ -20,6 +20,7 @@
 #define VLC_FIRSTRUNWIZARD_H
 
 #include "ui_firstrunwizard.h"
+#include "util/singleton.hpp"
 
 #include <QObject>
 #include <QWizard>
@@ -27,13 +28,11 @@
 class MLFoldersEditor;
 class MLFoldersModel;
 
-class FirstRunWizard : public QWizard
+class FirstRunWizard : public QWizard, public Singleton<FirstRunWizard>
 {
     Q_OBJECT
-public:
-    FirstRunWizard ( qt_intf_t*, QWidget* parent = nullptr );
-
 private:
+    explicit FirstRunWizard ( qt_intf_t*, QWidget* parent = nullptr );
     enum { WELCOME_PAGE, FOLDER_PAGE, COLOR_SCHEME_PAGE, LAYOUT_PAGE };
     enum { MODERN, CLASSIC };
 
@@ -63,6 +62,8 @@ private slots:
     void updateLayoutLabel (QAbstractButton* );
     void imageColorSchemeClick ( QAbstractButton* );
     void imageLayoutClick( QAbstractButton* );
+
+    friend class Singleton<FirstRunWizard>;
 };
 
 #endif // VLC_FIRSTRUNWIZARD_H


=====================================
modules/gui/qt/maininterface/main_interface.cpp
=====================================
@@ -206,6 +206,14 @@ MainInterface::MainInterface(qt_intf_t *_p_intf)
 
     /* Register callback for the intf-popupmenu variable */
     var_AddCallback( libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
+
+    if( config_GetInt("qt-privacy-ask") )
+    {
+        //postpone dialog call, as composition might not be ready yet
+        QMetaObject::invokeMethod(this, [this](){
+            THEDP->firstRunDialog();
+        }, Qt::QueuedConnection);
+    }
 }
 
 MainInterface::~MainInterface()



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

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




More information about the vlc-commits mailing list