Wrapped TimelineBody::track in a scoped_ptr
This commit is contained in:
parent
cd94bf9765
commit
1d376e4292
3 changed files with 8 additions and 13 deletions
|
|
@ -35,6 +35,7 @@
|
|||
#include <boost/optional.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include "lib/util.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ private:
|
|||
Shift
|
||||
};
|
||||
|
||||
timeline::Tool *tool;
|
||||
boost::scoped_ptr<timeline::Tool> tool;
|
||||
double mouseDownX, mouseDownY;
|
||||
|
||||
// Scroll State
|
||||
|
|
|
|||
Loading…
Reference in a new issue