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;
handimg = Gtk::manage (new RTImage ("openhand.png"));
handimg->reference();
editinghandimg = Gtk::manage (new RTImage ("editmodehand.png"));
editinghandimg->reference();
handimg.reset(new RTImage("openhand.png"));
editinghandimg.reset(new RTImage("editmodehand.png"));
handTool = Gtk::manage (new Gtk::ToggleButton ());
handTool->add (*handimg);
@ -48,10 +46,8 @@ ToolBar::ToolBar () : showColPickers(true), listener (nullptr), pickerListener(n
pack_start (*wbTool);
showcolpickersimg = Gtk::manage (new RTImage ("colorPickers-show.png"));
showcolpickersimg->reference();
hidecolpickersimg = Gtk::manage (new RTImage ("colorPickers-hide.png"));
hidecolpickersimg->reference();
showcolpickersimg.reset(new RTImage("colorPickers-show.png"));
hidecolpickersimg.reset(new RTImage("colorPickers-hide.png"));
colPickerTool = Gtk::manage (new Gtk::ToggleButton ());
colPickerTool->add (*showcolpickersimg);
@ -97,14 +93,6 @@ ToolBar::ToolBar () : showColPickers(true), listener (nullptr), pickerListener(n
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
//

View File

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