Undo resize operation correctly in File > Export w/Resize != 100% and without undo history

If we open a new image (there is no undo history) and use File > Export
with a Resize parameter, the resize command must be undone, but the
UndoState to return will be nullptr (nullptr is before the first UndoState,
which is the resize operation for the export operation). So without this
fix we just resize and cannot go back before the resize.

This regression was introduced in a4d1833a9c37aa95c67185ee8632bd4b9f8d84fc
This commit is contained in:
David Capello 2018-06-26 10:56:41 -03:00
parent b015fee8e0
commit 49106817d4

View File

@ -374,6 +374,7 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
// Apply scale
const undo::UndoState* undoState = nullptr;
bool undoResize = false;
if (xscale != 1.0 || yscale != 1.0) {
Command* resizeCmd = Commands::instance()->byId(CommandId::SpriteSize());
ASSERT(resizeCmd);
@ -387,6 +388,7 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
if (width != newWidth || height != newHeight) {
doc->setInhibitBackup(true);
undoState = doc->undoHistory()->currentState();
undoResize = true;
Params params;
params.set("use-ui", "false");
@ -432,7 +434,7 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
}
// Undo resize
if (undoState &&
if (undoResize &&
undoState != doc->undoHistory()->currentState()) {
moveToUndoState(doc, undoState);
doc->setInhibitBackup(false);