[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.
This commit is contained in:
David Capello 2023-02-24 12:50:33 -03:00
parent c3c1d29739
commit 24b273f806

View File

@ -30,6 +30,11 @@
#include <map> #include <map>
#include <memory> #include <memory>
// 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 app {
namespace script { namespace script {
@ -214,7 +219,9 @@ public:
Unknown = -1, Unknown = -1,
Change, Change,
FilenameChange, FilenameChange,
#if ENABLE_REMAP_TILESET_EVENT
RemapTileset, RemapTileset,
#endif
}; };
SpriteEvents(const Sprite* sprite) SpriteEvents(const Sprite* sprite)
@ -241,8 +248,10 @@ public:
return Change; return Change;
else if (std::strcmp(eventName, "filenamechange") == 0) else if (std::strcmp(eventName, "filenamechange") == 0)
return FilenameChange; return FilenameChange;
#if ENABLE_REMAP_TILESET_EVENT
else if (std::strcmp(eventName, "remaptileset") == 0) else if (std::strcmp(eventName, "remaptileset") == 0)
return RemapTileset; return RemapTileset;
#endif
else else
return Unknown; return Unknown;
} }
@ -261,12 +270,14 @@ public:
call(FilenameChange); call(FilenameChange);
} }
#if ENABLE_REMAP_TILESET_EVENT
void onRemapTileset(DocEvent& ev, const doc::Remap& remap) override { void onRemapTileset(DocEvent& ev, const doc::Remap& remap) override {
const bool fromUndo = (ev.document()->transaction() == nullptr); const bool fromUndo = (ev.document()->transaction() == nullptr);
call(RemapTileset, { { "remap", std::any(&remap) }, call(RemapTileset, { { "remap", std::any(&remap) },
{ "tileset", std::any((const doc::Tileset*)ev.tileset()) }, { "tileset", std::any((const doc::Tileset*)ev.tileset()) },
{ "fromUndo", fromUndo } }); { "fromUndo", fromUndo } });
} }
#endif
// DocUndoObserver impl // DocUndoObserver impl
void onAddUndoState(DocUndo* history) override { void onAddUndoState(DocUndo* history) override {