diff --git a/doc/python/pages/changelog.rst b/doc/python/pages/changelog.rst index 92e2968..3770d43 100644 --- a/doc/python/pages/changelog.rst +++ b/doc/python/pages/changelog.rst @@ -127,8 +127,9 @@ Changelog - Exposed the :ref:`text` library - Exposed the minimal interface of :ref:`utility.ConfigurationGroup` and :ref:`utility.Configuration` -- Exposed :ref:`pluginmanager.AbstractManager.set_preferred_plugins()`, the - base :ref:`pluginmanager.AbstractPlugin` class and +- Exposed :ref:`pluginmanager.AbstractManager.set_preferred_plugins()`, + :ref:`pluginmanager.AbstractManager.register_external_manager()`, the base + :ref:`pluginmanager.AbstractPlugin` class and :ref:`pluginmanager.PluginMetadata` - Fixed issues with an in-source build (see :gh:`mosra/magnum-bindings#13`) - All CMake build options are now prefixed with ``MAGNUM_``. For backwards diff --git a/src/python/corrade/pluginmanager.cpp b/src/python/corrade/pluginmanager.cpp index bf67c25..1b48963 100644 --- a/src/python/corrade/pluginmanager.cpp +++ b/src/python/corrade/pluginmanager.cpp @@ -144,7 +144,8 @@ void pluginmanager(py::module_& m) { } return state; - }, "Unload a plugin", py::arg("plugin")); + }, "Unload a plugin", py::arg("plugin")) + .def("register_external_manager", &PluginManager::AbstractManager::registerExternalManager, "Register an external manager for resolving inter-manager dependencies", py::arg("manager"), py::keep_alive<1, 2>()); py::class_>{m, "AbstractPlugin", "Base class for plugin interfaces"} /* Plugin interface string, search paths, suffix, metadata file suffix diff --git a/src/python/magnum/test/test_trade.py b/src/python/magnum/test/test_trade.py index 332b819..f80bbd9 100644 --- a/src/python/magnum/test/test_trade.py +++ b/src/python/magnum/test/test_trade.py @@ -1047,6 +1047,19 @@ class Importer(unittest.TestCase): with self.assertRaises(KeyError): manager.set_preferred_plugins('ApngImporter', []) + def test_register_external_manager(self): + # This scenario is stupid in practice, but want to test it on the + # Importer API for consistency + converter_manager = trade.ImageConverterManager() + converter_manager_refcount = sys.getrefcount(converter_manager) + + manager = trade.ImporterManager() + manager.register_external_manager(converter_manager) + self.assertEqual(sys.getrefcount(converter_manager), converter_manager_refcount + 1) + + del manager + self.assertEqual(sys.getrefcount(converter_manager), converter_manager_refcount) + def test_metadata(self): manager = trade.ImporterManager() manager.set_preferred_plugins('PngImporter', ['StbImageImporter'])