From 24b273f8061f5ab77e93f4ee99527bbc8f784695 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 24 Feb 2023 12:50:33 -0300 Subject: [PATCH] [lua] Remove "remaptileset" sprite event It's not safe to listen this event from a script because it can be called from a background thread. We keep the code for a future solution (in case that it can be found). In other case, consider to finally delete this code. --- src/app/script/events_class.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/script/events_class.cpp b/src/app/script/events_class.cpp index dcc7de47e..5f54c484c 100644 --- a/src/app/script/events_class.cpp +++ b/src/app/script/events_class.cpp @@ -30,6 +30,11 @@ #include #include +// This event was disabled because it can be triggered in a background thread +// when any effect (e.g. like Replace Color or Convolution Matrix) is running. +// And running script code in a background is not supported. +//#define ENABLE_REMAP_TILESET_EVENT + namespace app { namespace script { @@ -214,7 +219,9 @@ public: Unknown = -1, Change, FilenameChange, +#if ENABLE_REMAP_TILESET_EVENT RemapTileset, +#endif }; SpriteEvents(const Sprite* sprite) @@ -241,8 +248,10 @@ public: return Change; else if (std::strcmp(eventName, "filenamechange") == 0) return FilenameChange; +#if ENABLE_REMAP_TILESET_EVENT else if (std::strcmp(eventName, "remaptileset") == 0) return RemapTileset; +#endif else return Unknown; } @@ -261,12 +270,14 @@ public: call(FilenameChange); } +#if ENABLE_REMAP_TILESET_EVENT void onRemapTileset(DocEvent& ev, const doc::Remap& remap) override { const bool fromUndo = (ev.document()->transaction() == nullptr); call(RemapTileset, { { "remap", std::any(&remap) }, { "tileset", std::any((const doc::Tileset*)ev.tileset()) }, { "fromUndo", fromUndo } }); } +#endif // DocUndoObserver impl void onAddUndoState(DocUndo* history) override {