Reset tool preferences just once when running from CLI

This commit is contained in:
David Capello 2021-04-07 12:58:03 -03:00
parent 351900b4e7
commit a122f1ceba
2 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -183,6 +183,10 @@ DocumentPreferences& Preferences::document(const Doc* doc)
void Preferences::resetToolPreferences(tools::Tool* tool)
{
if (tool->prefAlreadyResetFromScript())
return;
tool->markPrefAlreadyResetFromScript();
auto it = m_tools.find(tool->getId());
if (it != m_tools.end())
m_tools.erase(it);

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -61,6 +62,9 @@ namespace app {
void setIntertwine(int button, Intertwine* intertwine) { m_button[button].m_intertwine = intertwine; }
void setTracePolicy(int button, TracePolicy trace_policy) { m_button[button].m_trace_policy = trace_policy; }
bool prefAlreadyResetFromScript() const { return m_prefAlreadyResetFromScript; }
void markPrefAlreadyResetFromScript() { m_prefAlreadyResetFromScript = true; }
private:
ToolGroup* m_group;
std::string m_id;
@ -68,6 +72,13 @@ namespace app {
std::string m_tips;
int m_default_brush_size;
// Flag used to indicate that the preferences of this tool were
// already reset from scripts when they are executed in CLI mode
// (without GUI). This is needed to reset the preferences only
// once, but if the script then modifies the preferences, they
// are not reset again.
bool m_prefAlreadyResetFromScript = false;
struct {
Fill m_fill;
Ink* m_ink;