diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 9376aae..c53652c 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -61,13 +61,13 @@ private: /** * @brief Append the underlying object of the given python object to the - * interface list for each type it matches. + * interface list if it is an instance (pointer) of the given type. * * @param obj The object to check. * @param interfaces The list to append the object to. * */ - template + template void appendIfInstance(bpy::object const& obj, QList &interfaces); /** @@ -1361,28 +1361,15 @@ void PythonRunner::initPath() Py_SetPath(paths.join(';').toStdWString().c_str()); } -template -struct appendIfInstance_Impl; -template -struct appendIfInstance_Impl { - static void apply(bpy::object const& obj, QList &interfaces) { - bpy::extract extr{ obj }; - if (extr.check()) { - interfaces.append(extr); - } - appendIfInstance_Impl::apply(obj, interfaces); - } -}; -template <> -struct appendIfInstance_Impl<> { - static void apply(bpy::object const& obj, QList &interfaces) { } -}; -template +template void PythonRunner::appendIfInstance(bpy::object const& obj, QList &interfaces) { - return appendIfInstance_Impl::apply(obj, interfaces); + bpy::extract extr{ obj }; + if (extr.check()) { + interfaces.append(extr); + } } QList PythonRunner::instantiate(const QString &pluginName) @@ -1406,19 +1393,16 @@ QList PythonRunner::instantiate(const QString &pluginName) bpy::object pluginObj = m_PythonObjects[pluginName]; QList interfaceList; - appendIfInstance< - IPluginGame, - // Must try the wrapper because it's only a plugin extension interface in C++, so doesn't extend QObject - IPluginDiagnoseWrapper, - // Must try the wrapper because it's only a plugin extension interface in C++, so doesn't extend QObject - IPluginFileMapperWrapper, - IPluginInstallerCustom, - IPluginInstallerSimple, - IPluginModPage, - IPluginPreview, - IPluginTool - > (pluginObj, interfaceList); - + appendIfInstance(pluginObj, interfaceList); + // Must try the wrapper because it's only a plugin extension interface in C++, so doesn't extend QObject + appendIfInstance(pluginObj, interfaceList); + // Must try the wrapper because it's only a plugin extension interface in C++, so doesn't extend QObject + appendIfInstance(pluginObj, interfaceList); + appendIfInstance(pluginObj, interfaceList); + appendIfInstance(pluginObj, interfaceList); + appendIfInstance(pluginObj, interfaceList); + appendIfInstance(pluginObj, interfaceList); + appendIfInstance(pluginObj, interfaceList); if (interfaceList.isEmpty()) appendIfInstance(pluginObj, interfaceList);