lua: Fix crash using Selection:deselect() when there is no selection

Fixes https://community.aseprite.org/t/6169
This commit is contained in:
David Capello 2020-06-17 17:13:37 -03:00
parent d75c9c443a
commit 6f048d10c5
2 changed files with 13 additions and 9 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -35,11 +35,13 @@ void DeselectMask::onUndo()
{
Doc* doc = document();
doc->setMask(m_oldMask.get());
doc->setMaskVisible(true);
doc->notifySelectionChanged();
if (m_oldMask) {
doc->setMask(m_oldMask.get());
doc->setMaskVisible(true);
m_oldMask.reset();
}
m_oldMask.reset();
doc->notifySelectionChanged();
}
size_t DeselectMask::onMemSize() const

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2015-2018 David Capello
//
// This program is distributed under the terms of
@ -116,9 +116,11 @@ int Selection_deselect(lua_State* L)
Doc* doc = static_cast<Doc*>(sprite->document());
ASSERT(doc);
Tx tx;
tx(new cmd::DeselectMask(doc));
tx.commit();
if (doc->isMaskVisible()) {
Tx tx;
tx(new cmd::DeselectMask(doc));
tx.commit();
}
}
else {
auto mask = obj->mask(L);