[vlc-commits] qt: set audioDeviceMenu non static
Thomas Guillem
git at videolan.org
Thu Mar 22 09:47:10 CET 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Mar 21 11:08:48 2018 +0100| [ef3978a7e1f1aa1477d4e884f45fb09c5d17d00a] | committer: Thomas Guillem
qt: set audioDeviceMenu non static
That way, we can attach vlc_objects to this menu without leaks.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ef3978a7e1f1aa1477d4e884f45fb09c5d17d00a
---
modules/gui/qt/menus.cpp | 16 ++++++++++------
modules/gui/qt/menus.hpp | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/modules/gui/qt/menus.cpp b/modules/gui/qt/menus.cpp
index cab6c16f52..3652827f72 100644
--- a/modules/gui/qt/menus.cpp
+++ b/modules/gui/qt/menus.cpp
@@ -80,7 +80,6 @@ enum
static QActionGroup *currentGroup;
QMenu *VLCMenuBar::recentsMenu = NULL;
-QMenu *VLCMenuBar::audioDeviceMenu = NULL;
QMenu *VLCMenuBar::rendererMenu = NULL;
QActionGroup *VLCMenuBar::rendererGroup = NULL;
@@ -611,28 +610,33 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
{
QVector<vlc_object_t *> objects;
QVector<const char *> varnames;
+ QMenu *audioDeviceMenu;
audio_output_t *p_aout;
input_thread_t *p_input;
- if (!audioDeviceMenu)
- audioDeviceMenu = new QMenu( qtr( "Audio &Device" ) );
-
if( current->isEmpty() )
{
addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
- current->addMenu( audioDeviceMenu );
+ audioDeviceMenu = addActionWithSubmenu( current, "audio-device", qtr( "Audio &Device" ) );
addActionWithSubmenu( current, "stereo-mode", qtr( "&Stereo Mode" ) );
current->addSeparator();
addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) );
VolumeEntries( p_intf, current );
}
+ else
+ {
+ QAction *action = FindActionWithVar( current, "audio-device" );
+ audioDeviceMenu = action ? action->menu() : NULL;
+ }
p_input = THEMIM->getInput();
p_aout = THEMIM->getAout();
EnableStaticEntries( current, ( p_aout != NULL ) );
AudioAutoMenuBuilder( p_input, objects, varnames );
- updateAudioDevice( p_intf, p_aout, audioDeviceMenu );
+ if( audioDeviceMenu )
+ updateAudioDevice( p_intf, p_aout, audioDeviceMenu );
+
if( p_aout )
{
vlc_object_release( p_aout );
diff --git a/modules/gui/qt/menus.hpp b/modules/gui/qt/menus.hpp
index 5bdd9bba58..1bc6519d61 100644
--- a/modules/gui/qt/menus.hpp
+++ b/modules/gui/qt/menus.hpp
@@ -152,7 +152,7 @@ private:
static void EnableStaticEntries( QMenu *, bool );
/* recentMRL menu */
- static QMenu *recentsMenu, *audioDeviceMenu;
+ static QMenu *recentsMenu;
static void updateAudioDevice( intf_thread_t *, audio_output_t *, QMenu* );
More information about the vlc-commits
mailing list