[vlc-devel] [PATCH] qt: fix crash when player has no audio output module

Pierre Lamot pierre at videolabs.io
Mon Sep 2 14:17:48 CEST 2019


---
 modules/gui/qt/components/audio_device_model.cpp | 8 ++++----
 modules/gui/qt/components/audio_device_model.hpp | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt/components/audio_device_model.cpp b/modules/gui/qt/components/audio_device_model.cpp
index cb2b9bfdf4..272e429128 100644
--- a/modules/gui/qt/components/audio_device_model.cpp
+++ b/modules/gui/qt/components/audio_device_model.cpp
@@ -46,8 +46,8 @@ AudioDeviceModel::AudioDeviceModel(vlc_player_t *player, QObject *parent)
     }
 
     m_aout = vlc_player_aout_Hold(m_player);
-
-    m_inputs = aout_DevicesList(m_aout, &m_ids, &m_names); 
+    if (m_aout)
+        m_inputs = aout_DevicesList(m_aout, &m_ids, &m_names);
 }
 
 AudioDeviceModel::~AudioDeviceModel()
@@ -66,8 +66,8 @@ AudioDeviceModel::~AudioDeviceModel()
     vlc_player_locker locker{m_player};
     vlc_player_aout_RemoveListener(m_player, m_player_aout_listener);
 
-    aout_Release(m_aout);
-
+    if (m_aout)
+        aout_Release(m_aout);
 }
 
 Qt::ItemFlags AudioDeviceModel::flags(const QModelIndex &) const
diff --git a/modules/gui/qt/components/audio_device_model.hpp b/modules/gui/qt/components/audio_device_model.hpp
index 1721990d5e..3b5fb6d419 100644
--- a/modules/gui/qt/components/audio_device_model.hpp
+++ b/modules/gui/qt/components/audio_device_model.hpp
@@ -52,7 +52,7 @@ public:
     QHash<int, QByteArray> roleNames() const override;
 
 private:
-    int m_inputs;
+    int m_inputs = 0;
     char **m_names;
     char **m_ids;
     QString m_current;
-- 
2.17.1



More information about the vlc-devel mailing list