Fix crash closing/reopening sprites when "keep closed sprite data in memory" is disabled

This commit is contained in:
David Capello 2020-02-27 12:02:01 -03:00
parent e3f28acf9e
commit 817c6e361f
2 changed files with 7 additions and 0 deletions

View File

@ -98,6 +98,9 @@ void BackupObserver::onRemoveDocument(Doc* doc)
base::remove_from_container(m_documents, doc);
}
if (doc->needsBackup() &&
// If the document is already fully backed up, we don't need to
// add it to the background thread to create its backup
!doc->isFullyBackedUp() &&
// If the backup is disabled, we don't need it (e.g. when the
// document is destroyed from a script with Sprite:close(), the
// backup is disabled)

View File

@ -81,6 +81,8 @@ void Doc::setContext(Context* ctx)
m_ctx = ctx;
if (ctx) {
DOC_TRACE("DOC: Removing as fully backed up", this);
// Remove the flag that indicates that this doc is fully backed
// up, because now we are inside a context, so the user can change
// it again and the backup will be outdated.
@ -260,6 +262,8 @@ void Doc::setInhibitBackup(const bool inhibitBackup)
void Doc::markAsBackedUp()
{
DOC_TRACE("DOC: Mark as fully backed up", this);
m_flags |= kFullyBackedUp;
}