From a122f1ceba8728c75164a7961b95025e3969abf9 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 7 Apr 2021 12:58:03 -0300 Subject: [PATCH] Reset tool preferences just once when running from CLI --- src/app/pref/preferences.cpp | 6 +++++- src/app/tools/tool.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/pref/preferences.cpp b/src/app/pref/preferences.cpp index 48d2deee4..dbb278504 100644 --- a/src/app/pref/preferences.cpp +++ b/src/app/pref/preferences.cpp @@ -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); diff --git a/src/app/tools/tool.h b/src/app/tools/tool.h index 7418898cf..1819c6036 100644 --- a/src/app/tools/tool.h +++ b/src/app/tools/tool.h @@ -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;