[glom] LayoutWidgetMenu: Use std::unique_ptr<> instead of naked new.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] LayoutWidgetMenu: Use std::unique_ptr<> instead of naked new.
- Date: Fri, 5 Feb 2016 11:20:33 +0000 (UTC)
commit 89dfe01916c4d71904146e6fdf03103f3154c8e4
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Feb 5 11:06:00 2016 +0100
LayoutWidgetMenu: Use std::unique_ptr<> instead of naked new.
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/layoutwidgetmenu.cc | 5 +----
glom/utility_widgets/layoutwidgetmenu.h | 2 +-
2 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/glom/utility_widgets/layoutwidgetmenu.cc b/glom/utility_widgets/layoutwidgetmenu.cc
index cc22e34..6322cc6 100644
--- a/glom/utility_widgets/layoutwidgetmenu.cc
+++ b/glom/utility_widgets/layoutwidgetmenu.cc
@@ -29,9 +29,6 @@ namespace Glom
{
LayoutWidgetMenu::LayoutWidgetMenu()
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- : m_pMenuPopup(nullptr)
-#endif
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
m_refActionGroup = Gio::SimpleActionGroup::create();
@@ -122,7 +119,7 @@ void LayoutWidgetMenu::setup_menu(Gtk::Widget* widget)
menu->append(_("Delete"), "context.delete");
- m_pMenuPopup = new Gtk::Menu(menu);
+ m_pMenuPopup = std::make_unique<Gtk::Menu>(menu);
m_pMenuPopup->attach_to_widget(*widget);
if(pApp)
diff --git a/glom/utility_widgets/layoutwidgetmenu.h b/glom/utility_widgets/layoutwidgetmenu.h
index ac28153..d94495d 100644
--- a/glom/utility_widgets/layoutwidgetmenu.h
+++ b/glom/utility_widgets/layoutwidgetmenu.h
@@ -49,7 +49,7 @@ public:
protected:
#ifndef GLOM_ENABLE_CLIENT_ONLY
- Gtk::Menu* m_pMenuPopup;
+ std::unique_ptr<Gtk::Menu> m_pMenuPopup;
//TODO_Performance: //Presumably we waste lots of memory by having this in each layout widget. Maybe we
can use one shared menu.
Glib::RefPtr<Gio::SimpleActionGroup> m_refActionGroup;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]