Show an error if we cannot create a ToolLoopImpl

The main issue at the moment is that a std::bad_alloc exception can be
thrown if there isn't enough memory available when the user click the
sprite editor to start drawing.
This commit is contained in:
David Capello 2013-11-10 16:20:20 -03:00
parent efbb3e52e2
commit 60602f78a8

View File

@ -360,15 +360,26 @@ tools::ToolLoop* create_tool_loop(Editor* editor, Context* context, MouseMessage
}
// Create the new tool loop
return
new ToolLoopImpl(editor,
context,
current_tool,
editor->getDocument(),
msg->left() ? tools::ToolLoop::Left:
tools::ToolLoop::Right,
msg->left() ? fg: bg,
msg->left() ? bg: fg);
try
{
return new ToolLoopImpl(editor,
context,
current_tool,
editor->getDocument(),
msg->left() ? tools::ToolLoop::Left:
tools::ToolLoop::Right,
msg->left() ? fg: bg,
msg->left() ? bg: fg);
}
catch (const std::exception& ex)
{
Alert::show(PACKAGE
"<<Error drawing ink:"
"<<%s"
"||&Close",
ex.what());
return NULL;
}
}
} // namespace app