TileSet Python export plugins (fixes #1865) by DrDub · Pull Request #3857 · mapeditor/tiled (original) (raw)
Extended the Python plugin to support custom tileset exporters and readers written in Python.
requested changes Jan 12, 2024
Un-duplicated setPythonClass function
Removed unused pluginmanager.h include
Fixed cleanup code related to reloading plugins in case a plugin changes from defining a map format to a tileset format or vice versa.
Allow a Python plugin to include both a map and a tileset format (though only one of each).
It appears Qt Creator's Qbs support does not include looking for compiler flags setting include paths (-I). They need to be actually set using cpp.includePaths.
There are actually no defines coming from python3-embed for me.
The problem was that handleError was not called when PyObject_IsSubclass returned -1, which it commonly did when called with a value that wasn't a class. With the error indicator still set, the next call to PyObject_Dir was failing.
Since the errors aren't usually very useful, we just call PyErr_Clear when PyObject_IsSubclass fails.
I couldn't find a convenient way to check if the value is a class, which could avoid raising these errors in the first place.
The PyErr_Print call already clears the error indicator, according to the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})