diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-08-24 08:44:48 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-08-24 08:44:48 +0200 |
commit | 6319cc457adf63c55920963a7a7cbb1398b8bbac (patch) | |
tree | 72eeda41d9aa9ac84bba5ff5af4da11114b7d0b5 /facetracknoir | |
parent | 1b8a80c2694c025ecf2a3bd0d1c0a934f91451ec (diff) |
ui: avoid potential memory leak
While not having tested with valgrind, setMenu() doesn't seem to take
ownership of QMenu. Ensure it's not leaked.
Diffstat (limited to 'facetracknoir')
-rw-r--r-- | facetracknoir/ui.cpp | 12 | ||||
-rw-r--r-- | facetracknoir/ui.h | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index e22fee7a..bd1b88f7 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -12,7 +12,6 @@ #include "facetracknoir/new_file_dialog.h" #include <QFileDialog> #include <QDesktopServices> -#include <QMenu> #ifndef _WIN32 # include <unistd.h> @@ -74,12 +73,11 @@ MainWindow::MainWindow() : connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); - auto menu = new QMenu; - menu->addAction("Create new empty config", this, SLOT(make_empty_config())); - menu->addAction("Create new copied config", this, SLOT(make_copied_config())); - menu->addAction("Open configuration directory", this, SLOT(open_config_directory())); - menu->addAction("Refresh configuration list", this, SLOT(refresh_config_list())); - ui.profile_button->setMenu(menu); + profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); + profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); + profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); + profile_menu.addAction("Refresh configuration list", this, SLOT(refresh_config_list())); + ui.profile_button->setMenu(&profile_menu); kbd_quit.setEnabled(true); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 4e89b143..9ecc0db9 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -15,6 +15,7 @@ #include <QTimer> #include <QSystemTrayIcon> #include <QString> +#include <QMenu> #include "ui_main.h" @@ -47,6 +48,7 @@ class MainWindow : public QMainWindow, private State mem<IProtocolDialog> pProtocolDialog; mem<ITrackerDialog> pTrackerDialog; process_detector_worker det; + QMenu profile_menu; mem<dylib> current_tracker() { |