[vlc-commits] Qt(menu): fix memory leak regarding static variables.
Erwan Tulou
git at videolan.org
Tue Nov 27 11:33:49 CET 2018
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Tue Nov 27 09:17:44 2018 +0100| [46dd65277fa57b05a015f7eb6fbd0b17f15c943b] | committer: Erwan Tulou
Qt(menu): fix memory leak regarding static variables.
This patch ensures the parentless menus (recentsMenu and RendererMenu)
are freed at the end of the vlc session.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=46dd65277fa57b05a015f7eb6fbd0b17f15c943b
---
modules/gui/qt/dialogs_provider.cpp | 4 ++++
modules/gui/qt/menus.hpp | 8 ++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/modules/gui/qt/dialogs_provider.cpp b/modules/gui/qt/dialogs_provider.cpp
index 32ee5b0d22..13634934ae 100644
--- a/modules/gui/qt/dialogs_provider.cpp
+++ b/modules/gui/qt/dialogs_provider.cpp
@@ -112,6 +112,10 @@ DialogsProvider::~DialogsProvider()
delete videoPopupMenu;
delete audioPopupMenu;
delete miscPopupMenu;
+
+ /* free parentless menus */
+ VLCMenuBar::freeRecentsMenu();
+ VLCMenuBar::freeRendererMenu();
}
QString DialogsProvider::getSaveFileName( QWidget *parent,
diff --git a/modules/gui/qt/menus.hpp b/modules/gui/qt/menus.hpp
index bfa0c818cc..ffa7fa704f 100644
--- a/modules/gui/qt/menus.hpp
+++ b/modules/gui/qt/menus.hpp
@@ -84,6 +84,10 @@ public:
static void updateSystrayMenu( MainInterface *, intf_thread_t *,
bool b_force_visible = false);
+ /* destructor for parentless Menus (kept in static variables) */
+ static void freeRendererMenu(){ delete rendererMenu; rendererMenu = NULL; }
+ static void freeRecentsMenu(){ delete recentsMenu; recentsMenu = NULL; }
+
/* Actions */
static void DoAction( QObject * );
enum actionflag {
@@ -96,8 +100,6 @@ public:
};
Q_DECLARE_FLAGS(actionflags, actionflag)
- static RendererMenu *rendererMenu;
-
private:
/* All main Menus */
static QMenu *FileMenu( intf_thread_t *, QWidget *, MainInterface * mi = NULL );
@@ -154,6 +156,8 @@ private:
/* recentMRL menu */
static QMenu *recentsMenu;
+ static RendererMenu *rendererMenu;
+
static void updateAudioDevice( intf_thread_t *, audio_output_t *, QMenu* );
public slots:
More information about the vlc-commits
mailing list