[vlc-commits] [Git][videolan/vlc][master] qt: make sure playlist model recovery is not initialized during shutdown

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Oct 16 12:47:47 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
f26606eb by Fatih Uzunoglu at 2025-10-16T12:20:59+00:00
qt: make sure playlist model recovery is not initialized during shutdown

We are queuing the initialization to not slow down the start. However,
if -for any reason- the application is already closing before the queued
slot was executed, then we should make sure to not initialize the model
recovery as not only it would not make any sense, but also may cause
null pointer dereference because the model or settings may be gone.

- - - - -


1 changed file:

- modules/gui/qt/qt.cpp


Changes:

=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -1031,12 +1031,16 @@ static void *Thread( void *obj )
     p_intf->p_mainPlayerController = new PlayerController(p_intf);
     p_intf->p_mainPlaylistController = new vlc::playlist::PlaylistController(p_intf->p_playlist);
 
-    std::unique_ptr<ModelRecoveryAgent> playlistModelRecoveryAgent;
-    QMetaObject::invokeMethod(&app, [&playlistModelRecoveryAgent, p_intf]() {
+    std::optional playlistModelRecoveryAgent = std::unique_ptr<ModelRecoveryAgent>();
+    QMetaObject::invokeMethod(&app, [&playlistModelRecoveryAgent, settings = QPointer(p_intf->mainSettings), mpc = QPointer(p_intf->p_mainPlaylistController)]() {
+        if (Q_UNLIKELY(!playlistModelRecoveryAgent)) // std::optional is nullopt, reset() was already called
+            return;
+        if (Q_UNLIKELY(!settings || !mpc))
+            return;
         try {
-            playlistModelRecoveryAgent = std::make_unique<ModelRecoveryAgent>(p_intf->mainSettings,
+            playlistModelRecoveryAgent = std::make_unique<ModelRecoveryAgent>(settings.get(),
                                                                               QStringLiteral("Playlist"),
-                                                                              p_intf->p_mainPlaylistController);
+                                                                              mpc.get());
         } catch (...){ }
     }, Qt::QueuedConnection);
 



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/f26606eb180acb92e63e978c03307309cd7bb52e
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