mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Fix lua error crash (fix #2635)
Prevents crashes from uncaught exceptions generated from Lua errors when running aseprite from the console with -script param.
This commit is contained in:
parent
2dccb6d646
commit
1193bf18fc
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
// Copyright (C) 2018-2021 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
|
||||||
@ -334,6 +334,7 @@ int App::initialize(const AppOptions& options)
|
|||||||
|
|
||||||
// Process options
|
// Process options
|
||||||
LOG("APP: Processing options...\n");
|
LOG("APP: Processing options...\n");
|
||||||
|
int code;
|
||||||
{
|
{
|
||||||
std::unique_ptr<CliDelegate> delegate;
|
std::unique_ptr<CliDelegate> delegate;
|
||||||
if (options.previewCLI())
|
if (options.previewCLI())
|
||||||
@ -342,14 +343,12 @@ int App::initialize(const AppOptions& options)
|
|||||||
delegate.reset(new DefaultCliDelegate);
|
delegate.reset(new DefaultCliDelegate);
|
||||||
|
|
||||||
CliProcessor cli(delegate.get(), options);
|
CliProcessor cli(delegate.get(), options);
|
||||||
int code = cli.process(context());
|
code = cli.process(context());
|
||||||
if (code != 0)
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("APP: Finish launching...\n");
|
LOG("APP: Finish launching...\n");
|
||||||
system->finishLaunching();
|
system->finishLaunching();
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::run()
|
void App::run()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
// Copyright (C) 2018-2021 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
|
||||||
@ -532,7 +532,14 @@ int CliProcessor::process(Context* ctx)
|
|||||||
// --script <filename>
|
// --script <filename>
|
||||||
else if (opt == &m_options.script()) {
|
else if (opt == &m_options.script()) {
|
||||||
std::string filename = value.value();
|
std::string filename = value.value();
|
||||||
int code = m_delegate->execScript(filename, scriptParams);
|
int code;
|
||||||
|
try {
|
||||||
|
code = m_delegate->execScript(filename, scriptParams);
|
||||||
|
}
|
||||||
|
catch (const std::exception& ex) {
|
||||||
|
Console::showException(ex);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (code != 0)
|
if (code != 0)
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
// Copyright (C) 2018-2021 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
|
||||||
@ -179,7 +179,6 @@ void Console::printf(const char* format, ...)
|
|||||||
// static
|
// static
|
||||||
void Console::showException(const std::exception& e)
|
void Console::showException(const std::exception& e)
|
||||||
{
|
{
|
||||||
ui::assert_ui_thread();
|
|
||||||
if (!ui::is_ui_thread()) {
|
if (!ui::is_ui_thread()) {
|
||||||
LOG(ERROR, "A problem has occurred.\n\nDetails:\n%s\n", e.what());
|
LOG(ERROR, "A problem has occurred.\n\nDetails:\n%s\n", e.what());
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -95,14 +95,15 @@ int app_main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int code = app.initialize(options);
|
const int code = app.initialize(options);
|
||||||
if (code != 0)
|
|
||||||
return code;
|
|
||||||
|
|
||||||
if (options.startShell())
|
if (options.startShell())
|
||||||
systemConsole.prepareShell();
|
systemConsole.prepareShell();
|
||||||
|
|
||||||
app.run();
|
app.run();
|
||||||
return 0;
|
|
||||||
|
// After starting the GUI, we'll always return 0, but in batch
|
||||||
|
// mode we can return the error code.
|
||||||
|
return (app.isGui() ? 0: code);
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
std::cerr << e.what() << '\n';
|
std::cerr << e.what() << '\n';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user