diff --git a/src/gui/gtk-lumiera.hpp b/src/gui/gtk-lumiera.hpp index e0bb55310..3efebeb65 100644 --- a/src/gui/gtk-lumiera.hpp +++ b/src/gui/gtk-lumiera.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "lib/util.hpp" extern "C" { diff --git a/src/gui/widgets/timeline/timeline-body.cpp b/src/gui/widgets/timeline/timeline-body.cpp index 3e1f06d9b..e755ddaad 100644 --- a/src/gui/widgets/timeline/timeline-body.cpp +++ b/src/gui/widgets/timeline/timeline-body.cpp @@ -58,42 +58,36 @@ TimelineBody::TimelineBody(TimelineWidget &timeline_widget) : TimelineBody::~TimelineBody() { - REQUIRE(tool != NULL); - if(tool != NULL) - delete tool; + WARN_IF(!tool, gui, "An invalid tool pointer is unexpected here"); } ToolType TimelineBody::get_tool() const { - REQUIRE(tool != NULL); - if(tool != NULL) - return tool->get_type(); - return gui::widgets::timeline::None; + REQUIRE(tool); + return tool->get_type(); } void TimelineBody::set_tool(timeline::ToolType tool_type) { // Tidy up old tool - if(tool != NULL) + if(tool) { // Do we need to change tools? if(tool->get_type() == tool_type) return; - - delete tool; } // Create the new tool switch(tool_type) { case timeline::Arrow: - tool = new ArrowTool(*this); + tool.reset(new ArrowTool(*this)); break; case timeline::IBeam: - tool = new IBeamTool(*this); + tool.reset(new IBeamTool(*this)); break; default: diff --git a/src/gui/widgets/timeline/timeline-body.hpp b/src/gui/widgets/timeline/timeline-body.hpp index a7584cdfc..683a59dec 100644 --- a/src/gui/widgets/timeline/timeline-body.hpp +++ b/src/gui/widgets/timeline/timeline-body.hpp @@ -160,7 +160,7 @@ private: Shift }; - timeline::Tool *tool; + boost::scoped_ptr tool; double mouseDownX, mouseDownY; // Scroll State