From 8405add1376620a8cb0eeaf39f0b53b7dab5a96a Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 7 Jun 2019 18:39:36 -0300 Subject: [PATCH] Fix error using an invalid crop_image() with Width < 1, Height < 1 when using New Brush with right-click outside the canvas bounds --- src/app/commands/cmd_new_brush.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/commands/cmd_new_brush.cpp b/src/app/commands/cmd_new_brush.cpp index b7be758e4..d98d1e67b 100644 --- a/src/app/commands/cmd_new_brush.cpp +++ b/src/app/commands/cmd_new_brush.cpp @@ -113,9 +113,12 @@ void NewBrushCommand::onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::M try { ContextWriter writer(UIContext::instance(), 250); if (writer.cel()) { - Tx tx(writer.context(), "Clear"); - tx(new cmd::ClearRect(writer.cel(), rect)); - tx.commit(); + gfx::Rect canvasRect = (rect & writer.cel()->bounds()); + if (!canvasRect.isEmpty()) { + Tx tx(writer.context(), "Clear"); + tx(new cmd::ClearRect(writer.cel(), canvasRect)); + tx.commit(); + } } } catch (const std::exception& ex) {