Fix error using an invalid crop_image() with Width < 1, Height < 1 when using New Brush with right-click outside the canvas bounds

This commit is contained in:
David Capello 2019-06-07 18:39:36 -03:00
parent 8281e49798
commit 8405add137

View File

@ -113,11 +113,14 @@ void NewBrushCommand::onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::M
try { try {
ContextWriter writer(UIContext::instance(), 250); ContextWriter writer(UIContext::instance(), 250);
if (writer.cel()) { if (writer.cel()) {
gfx::Rect canvasRect = (rect & writer.cel()->bounds());
if (!canvasRect.isEmpty()) {
Tx tx(writer.context(), "Clear"); Tx tx(writer.context(), "Clear");
tx(new cmd::ClearRect(writer.cel(), rect)); tx(new cmd::ClearRect(writer.cel(), canvasRect));
tx.commit(); tx.commit();
} }
} }
}
catch (const std::exception& ex) { catch (const std::exception& ex) {
Console::showException(ex); Console::showException(ex);
} }