mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
lua: Dialog() must return nil if there is no UI available
This avoids some crashes when running in --batch mode and some script tries to create a Dialog().
This commit is contained in:
parent
be7c26da5e
commit
2a908f79df
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -80,7 +80,10 @@ void RunScriptCommand::onExecute(Context* context)
|
||||
->scriptEngine()
|
||||
->evalFile(m_filename, m_params);
|
||||
|
||||
ui::Manager::getDefault()->invalidate();
|
||||
#if ENABLE_UI
|
||||
if (context->isUIAvailable())
|
||||
ui::Manager::getDefault()->invalidate();
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string RunScriptCommand::onGetFriendlyName() const
|
||||
|
@ -10,6 +10,6 @@
|
||||
|
||||
// Increment this value if the scripting API is modified between two
|
||||
// released Aseprite versions.
|
||||
#define API_VERSION 17
|
||||
#define API_VERSION 18
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -201,6 +201,10 @@ void Dialog_connect_signal(lua_State* L,
|
||||
|
||||
int Dialog_new(lua_State* L)
|
||||
{
|
||||
// If we don't have UI, just return nil
|
||||
if (!App::instance()->isGui())
|
||||
return 0;
|
||||
|
||||
auto dlg = push_new<Dialog>(L);
|
||||
|
||||
// The uservalue of the dialog userdata will contain a table that
|
||||
|
Loading…
x
Reference in New Issue
Block a user