Commit 89dfe019 authored by Murray Cumming's avatar Murray Cumming
Browse files

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.
parent e542cfff
......@@ -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)
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment