[glom] Db_AddDel: Use std::unique_ptr<> for the menu, instead of new and delete.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Db_AddDel: Use std::unique_ptr<> for the menu, instead of new and delete.
- Date: Fri, 5 Feb 2016 11:19:53 +0000 (UTC)
commit b32655d13c87f3ea4152411e7eef3440a84e9d13
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Feb 5 10:23:37 2016 +0100
Db_AddDel: Use std::unique_ptr<> for the menu, instead of new and delete.
I am not very happy with passing the raw pointer to gtkmm's
attach_to_widget(), but that seems to be the normal use of
unique_ptr<>::operator*() and unique_ptr<>::get(),
as long as we don't expect the receiving API to take any
ownership.
glom/mode_data/db_adddel/db_adddel.cc | 3 +--
glom/mode_data/db_adddel/db_adddel.h | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index 26f1f2d..6b266e6 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -46,7 +46,6 @@ DbAddDel::DbAddDel()
m_column_is_sorted(false),
m_column_sorted_direction(false),
m_column_sorted(0),
- m_pMenuPopup(nullptr),
m_bAllowUserActions(true),
m_bPreventUserSignals(false),
m_bIgnoreTreeViewSignals(false),
@@ -260,7 +259,7 @@ void DbAddDel::setup_menu(Gtk::Widget* /* widget */)
menu->append(_("_Layout"), "context.layout");
#endif
- m_pMenuPopup = new Gtk::Menu(menu);
+ m_pMenuPopup = std::make_unique<Gtk::Menu>(menu);
m_pMenuPopup->attach_to_widget(*this);
if(get_allow_user_actions())
diff --git a/glom/mode_data/db_adddel/db_adddel.h b/glom/mode_data/db_adddel/db_adddel.h
index 54eccf4..3861ba5 100644
--- a/glom/mode_data/db_adddel/db_adddel.h
+++ b/glom/mode_data/db_adddel/db_adddel.h
@@ -402,7 +402,7 @@ protected:
private:
//TODO: Avoid repeating these in so many widgets:
- Gtk::Menu* m_pMenuPopup;
+ std::unique_ptr<Gtk::Menu> m_pMenuPopup;
Glib::RefPtr<Gio::SimpleActionGroup> m_refActionGroup;
Glib::RefPtr<Gio::SimpleAction> m_refContextEdit, m_refContextAdd, m_refContextDelete;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]