valgrind: Fix two memory leaks in toolbar

This commit is contained in:
heckflosse 2017-07-02 16:23:28 +02:00
parent 137450ce7a
commit aae7794587
2 changed files with 8 additions and 21 deletions

View File

@ -26,10 +26,8 @@ ToolBar::ToolBar () : showColPickers(true), listener (nullptr), pickerListener(n
editingMode = false; editingMode = false;
handimg = Gtk::manage (new RTImage ("openhand.png")); handimg.reset(new RTImage("openhand.png"));
handimg->reference(); editinghandimg.reset(new RTImage("editmodehand.png"));
editinghandimg = Gtk::manage (new RTImage ("editmodehand.png"));
editinghandimg->reference();
handTool = Gtk::manage (new Gtk::ToggleButton ()); handTool = Gtk::manage (new Gtk::ToggleButton ());
handTool->add (*handimg); handTool->add (*handimg);
@ -48,10 +46,8 @@ ToolBar::ToolBar () : showColPickers(true), listener (nullptr), pickerListener(n
pack_start (*wbTool); pack_start (*wbTool);
showcolpickersimg = Gtk::manage (new RTImage ("colorPickers-show.png")); showcolpickersimg.reset(new RTImage("colorPickers-show.png"));
showcolpickersimg->reference(); hidecolpickersimg.reset(new RTImage("colorPickers-hide.png"));
hidecolpickersimg = Gtk::manage (new RTImage ("colorPickers-hide.png"));
hidecolpickersimg->reference();
colPickerTool = Gtk::manage (new Gtk::ToggleButton ()); colPickerTool = Gtk::manage (new Gtk::ToggleButton ());
colPickerTool->add (*showcolpickersimg); colPickerTool->add (*showcolpickersimg);
@ -97,14 +93,6 @@ ToolBar::ToolBar () : showColPickers(true), listener (nullptr), pickerListener(n
straTool->set_tooltip_markup (M("TOOLBAR_TOOLTIP_STRAIGHTEN")); straTool->set_tooltip_markup (M("TOOLBAR_TOOLTIP_STRAIGHTEN"));
} }
ToolBar::~ToolBar ()
{
handimg->unreference();
editinghandimg->unreference();
showcolpickersimg->unreference();
hidecolpickersimg->unreference();
}
// //
// Selects the desired tool without notifying the listener // Selects the desired tool without notifying the listener
// //

View File

@ -39,10 +39,10 @@ public:
class ToolBar : public Gtk::HBox class ToolBar : public Gtk::HBox
{ {
private: private:
RTImage* handimg; std::unique_ptr<RTImage> handimg;
RTImage* editinghandimg; std::unique_ptr<RTImage> editinghandimg;
RTImage* showcolpickersimg; std::unique_ptr<RTImage> showcolpickersimg;
RTImage* hidecolpickersimg; std::unique_ptr<RTImage> hidecolpickersimg;
bool showColPickers; bool showColPickers;
void hand_pressed (); void hand_pressed ();
@ -72,7 +72,6 @@ protected:
public: public:
ToolBar (); ToolBar ();
~ToolBar ();
void setTool (ToolMode tool); void setTool (ToolMode tool);
ToolMode getTool () ToolMode getTool ()