[glom] NotebookLabel: Use std::unique_ptr<> for the menu, instead of new and delete.



commit 912b4eb07c933b2cbfcb9f55f93bc1652b6c89d8
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Feb 5 10:56:44 2016 +0100

    NotebookLabel: 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/utility_widgets/notebooklabelglom.cc |    2 +-
 glom/utility_widgets/notebooklabelglom.h  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glom/utility_widgets/notebooklabelglom.cc b/glom/utility_widgets/notebooklabelglom.cc
index b1da6d8..1211cfd 100644
--- a/glom/utility_widgets/notebooklabelglom.cc
+++ b/glom/utility_widgets/notebooklabelglom.cc
@@ -119,7 +119,7 @@ void NotebookLabel::setup_menu(Gtk::Widget* /* widget */)
   menu->append(_("New Group"), "context.new-group");
   menu->append(_("_Delete"), "context.delete");
 
-  m_pPopupMenu = new Gtk::Menu(menu);
+  m_pPopupMenu = std::make_unique<Gtk::Menu>(menu);
   m_pPopupMenu->attach_to_widget(*this);
 }
 
diff --git a/glom/utility_widgets/notebooklabelglom.h b/glom/utility_widgets/notebooklabelglom.h
index ff23b21..680c82d 100644
--- a/glom/utility_widgets/notebooklabelglom.h
+++ b/glom/utility_widgets/notebooklabelglom.h
@@ -50,7 +50,7 @@ private:
   NotebookGlom* m_notebook;
   
   void setup_menu(Gtk::Widget* widget);
-  Gtk::Menu* m_pPopupMenu;
+  std::unique_ptr<Gtk::Menu> m_pPopupMenu;
   
   void on_menu_new_group_activate();
   void on_menu_delete_activate();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]