mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-28 18:32:50 +00:00
Fix possible crash adding reference layer (fix #3949)
This commit is contained in:
parent
d39a656bb4
commit
f92f14f261
@ -18,6 +18,7 @@
|
|||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
#include "app/commands/new_params.h"
|
#include "app/commands/new_params.h"
|
||||||
#include "app/commands/params.h"
|
#include "app/commands/params.h"
|
||||||
|
#include "app/console.h"
|
||||||
#include "app/context_access.h"
|
#include "app/context_access.h"
|
||||||
#include "app/doc_api.h"
|
#include "app/doc_api.h"
|
||||||
#include "app/find_widget.h"
|
#include "app/find_widget.h"
|
||||||
@ -170,8 +171,14 @@ void NewLayerCommand::onExecute(Context* context)
|
|||||||
Scoped destroyPasteDoc(
|
Scoped destroyPasteDoc(
|
||||||
[&pasteDoc, context]{
|
[&pasteDoc, context]{
|
||||||
if (pasteDoc) {
|
if (pasteDoc) {
|
||||||
DocDestroyer destroyer(context, pasteDoc, 100);
|
try {
|
||||||
destroyer.destroyDocument();
|
DocDestroyer destroyer(context, pasteDoc, 1000);
|
||||||
|
destroyer.destroyDocument();
|
||||||
|
}
|
||||||
|
catch (const CannotWriteDocException& e) {
|
||||||
|
LOG(ERROR, "%s\n", e.what());
|
||||||
|
Console::showException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -192,6 +199,9 @@ void NewLayerCommand::onExecute(Context* context)
|
|||||||
// The user have selected another document.
|
// The user have selected another document.
|
||||||
if (oldActiveDocument != context->activeDocument()) {
|
if (oldActiveDocument != context->activeDocument()) {
|
||||||
pasteDoc = context->activeDocument();
|
pasteDoc = context->activeDocument();
|
||||||
|
if (pasteDoc)
|
||||||
|
pasteDoc->setInhibitBackup(true);
|
||||||
|
|
||||||
static_cast<UIContext*>(context)
|
static_cast<UIContext*>(context)
|
||||||
->setActiveDocument(oldActiveDocument);
|
->setActiveDocument(oldActiveDocument);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user