mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +00:00
Handle exceptions that DocDestroyer can throw (probably #4367)
This commit is contained in:
parent
b8514ad1c6
commit
7f659d2f86
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
// Copyright (C) 2019-2024 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/commands/cmd_export_sprite_sheet.h"
|
#include "app/commands/cmd_export_sprite_sheet.h"
|
||||||
|
#include "app/console.h"
|
||||||
#include "app/context.h"
|
#include "app/context.h"
|
||||||
#include "app/context_access.h"
|
#include "app/context_access.h"
|
||||||
#include "app/doc.h"
|
#include "app/doc.h"
|
||||||
@ -141,6 +142,17 @@ ConstraintType constraint_type_from_params(const ExportSpriteSheetParams& params
|
|||||||
|
|
||||||
#endif // ENABLE_UI
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
|
void destroy_doc(Context* ctx, Doc* doc)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
DocDestroyer destroyer(ctx, doc, 500);
|
||||||
|
destroyer.destroyDocument();
|
||||||
|
}
|
||||||
|
catch (const LockedDocException& ex) {
|
||||||
|
Console::showException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Doc* generate_sprite_sheet_from_params(
|
Doc* generate_sprite_sheet_from_params(
|
||||||
DocExporter& exporter,
|
DocExporter& exporter,
|
||||||
Context* ctx,
|
Context* ctx,
|
||||||
@ -500,8 +512,7 @@ public:
|
|||||||
auto ctx = UIContext::instance();
|
auto ctx = UIContext::instance();
|
||||||
ctx->setActiveDocument(m_site.document());
|
ctx->setActiveDocument(m_site.document());
|
||||||
|
|
||||||
DocDestroyer destroyer(ctx, m_spriteSheet.release(), 100);
|
destroy_doc(ctx, m_spriteSheet.release());
|
||||||
destroyer.destroyDocument();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1014,8 +1025,7 @@ private:
|
|||||||
auto ctx = UIContext::instance();
|
auto ctx = UIContext::instance();
|
||||||
ctx->setActiveDocument(m_site.document());
|
ctx->setActiveDocument(m_site.document());
|
||||||
|
|
||||||
DocDestroyer destroyer(ctx, m_spriteSheet.release(), 100);
|
destroy_doc(ctx, m_spriteSheet.release());
|
||||||
destroyer.destroyDocument();
|
|
||||||
m_editor = nullptr;
|
m_editor = nullptr;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1066,8 +1076,7 @@ private:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (token.canceled()) {
|
if (token.canceled()) {
|
||||||
DocDestroyer destroyer(&tmpCtx, newDocument, 100);
|
destroy_doc(&tmpCtx, newDocument);
|
||||||
destroyer.destroyDocument();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1090,8 +1099,7 @@ private:
|
|||||||
// old one. IN this case the newDocument contains a back
|
// old one. IN this case the newDocument contains a back
|
||||||
// buffer (ImageBufferPtr) that will be discarded.
|
// buffer (ImageBufferPtr) that will be discarded.
|
||||||
m_executionID != executionID) {
|
m_executionID != executionID) {
|
||||||
DocDestroyer destroyer(context, newDocument, 100);
|
destroy_doc(context, newDocument);
|
||||||
destroyer.destroyDocument();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,8 +1145,7 @@ private:
|
|||||||
|
|
||||||
m_spriteSheet->notifyGeneralUpdate();
|
m_spriteSheet->notifyGeneralUpdate();
|
||||||
|
|
||||||
DocDestroyer destroyer(context, newDocument, 100);
|
destroy_doc(context, newDocument);
|
||||||
destroyer.destroyDocument();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
waitGenTaskAndDelete();
|
waitGenTaskAndDelete();
|
||||||
@ -1407,8 +1414,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
|
|||||||
newDocument.release();
|
newDocument.release();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DocDestroyer destroyer(context, newDocument.release(), 100);
|
destroy_doc(context, newDocument.release());
|
||||||
destroyer.destroyDocument();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
// Copyright (C) 2019-2024 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -13,6 +13,7 @@
|
|||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
#include "app/commands/new_params.h"
|
#include "app/commands/new_params.h"
|
||||||
|
#include "app/console.h"
|
||||||
#include "app/context.h"
|
#include "app/context.h"
|
||||||
#include "app/context_access.h"
|
#include "app/context_access.h"
|
||||||
#include "app/doc_access.h"
|
#include "app/doc_access.h"
|
||||||
@ -264,8 +265,13 @@ private:
|
|||||||
releaseEditor();
|
releaseEditor();
|
||||||
|
|
||||||
if (m_fileOpened) {
|
if (m_fileOpened) {
|
||||||
DocDestroyer destroyer(m_context, oldDocument, 100);
|
try {
|
||||||
destroyer.destroyDocument();
|
DocDestroyer destroyer(m_context, oldDocument, 500);
|
||||||
|
destroyer.destroyDocument();
|
||||||
|
}
|
||||||
|
catch (const LockedDocException& ex) {
|
||||||
|
Console::showException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user