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,9 +113,12 @@ 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()) {
Tx tx(writer.context(), "Clear"); gfx::Rect canvasRect = (rect & writer.cel()->bounds());
tx(new cmd::ClearRect(writer.cel(), rect)); if (!canvasRect.isEmpty()) {
tx.commit(); Tx tx(writer.context(), "Clear");
tx(new cmd::ClearRect(writer.cel(), canvasRect));
tx.commit();
}
} }
} }
catch (const std::exception& ex) { catch (const std::exception& ex) {