[glom] ImageGlom: Use std::unique_ptr<> instead of naked new.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] ImageGlom: Use std::unique_ptr<> instead of naked new.
- Date: Fri, 5 Feb 2016 11:20:28 +0000 (UTC)
commit e542cfffb53b5622c1575502e0ad6082341baba3
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Feb 5 11:04:35 2016 +0100
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.
glom/utility_widgets/imageglom.cc | 9 +++------
glom/utility_widgets/imageglom.h | 2 +-
2 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/glom/utility_widgets/imageglom.cc b/glom/utility_widgets/imageglom.cc
index ba76c18..3149d1b 100644
--- a/glom/utility_widgets/imageglom.cc
+++ b/glom/utility_widgets/imageglom.cc
@@ -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);
}
diff --git a/glom/utility_widgets/imageglom.h b/glom/utility_widgets/imageglom.h
index 7f9504e..d57a365 100644
--- a/glom/utility_widgets/imageglom.h
+++ b/glom/utility_widgets/imageglom.h
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]