Commit e542cfff authored by Murray Cumming's avatar Murray Cumming
Browse files

ImageGlom: 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 29577255
......@@ -49,8 +49,7 @@ ImageGlom::type_vec_ustrings ImageGlom::m_gdkpixbuf_supported_mime_types;
ImageGlom::ImageGlom()
: m_ev_view(nullptr),
m_ev_document_model(nullptr),
m_pMenuPopup_UserMode(nullptr)
m_ev_document_model(nullptr)
{
init();
}
......@@ -58,8 +57,7 @@ ImageGlom::ImageGlom()
ImageGlom::ImageGlom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& /* builder */)
: Gtk::EventBox(cobject),
m_ev_view(nullptr),
m_ev_document_model(nullptr),
m_pMenuPopup_UserMode(nullptr)
m_ev_document_model(nullptr)
{
init();
}
......@@ -97,7 +95,6 @@ void ImageGlom::init()
ImageGlom::~ImageGlom()
{
delete m_pMenuPopup_UserMode;
}
void ImageGlom::set_layout_item(const std::shared_ptr<LayoutItem>& layout_item, const Glib::ustring& table_name)
......@@ -948,7 +945,7 @@ void ImageGlom::setup_menu_usermode()
menu->append(_("_Paste"), "context.paste");
menu->append(_("_Clear"), "context.clear");
m_pMenuPopup_UserMode = new Gtk::Menu(menu);
m_pMenuPopup_UserMode = std::make_unique<Gtk::Menu>(menu);
m_pMenuPopup_UserMode->attach_to_widget(*this);
}
......
......@@ -118,7 +118,7 @@ private:
Glib::RefPtr<Gdk::Pixbuf> m_pixbuf_clipboard; //When copy is used, store it here until it is pasted.
Gtk::Menu* m_pMenuPopup_UserMode;
std::unique_ptr<Gtk::Menu> m_pMenuPopup_UserMode;
//TODO: Use just the Gio::ActionGroup type when it derives from Gio::ActionMap.
Glib::RefPtr<Gio::SimpleActionGroup> m_refActionGroup_UserModePopup;
......
Markdown is supported
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