diff --git a/src/proxy/proxypython.cpp b/src/proxy/proxypython.cpp index b28b2a8..d4fe3d6 100644 --- a/src/proxy/proxypython.cpp +++ b/src/proxy/proxypython.cpp @@ -225,13 +225,13 @@ QStringList ProxyPython::pluginList(const QString &pluginPath) const } -QObject *ProxyPython::instantiate(const QString &pluginName) +QList ProxyPython::instantiate(const QString &pluginName) { if (m_Runner != nullptr) { - QObject *result = m_Runner->instantiate(pluginName); + QList result = m_Runner->instantiate(pluginName); return result; } else { - return nullptr; + return QList(); } } diff --git a/src/proxy/proxypython.h b/src/proxy/proxypython.h index e3c8c23..a41f856 100644 --- a/src/proxy/proxypython.h +++ b/src/proxy/proxypython.h @@ -49,7 +49,7 @@ public: virtual QList settings() const; QStringList pluginList(const QString &pluginPath) const; - QObject *instantiate(const QString &pluginName); + QList instantiate(const QString &pluginName); /** * @return the parent widget for newly created dialogs diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 7578949..48d3d97 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -37,7 +37,7 @@ class PythonRunner : public IPythonRunner public: PythonRunner(const MOBase::IOrganizer *moInfo); bool initPython(const QString &pythonDir); - QObject *instantiate(const QString &pluginName); + QList instantiate(const QString &pluginName); bool isPythonInstalled() const; bool isPythonVersionSupported() const; @@ -1266,7 +1266,7 @@ bool handled_exec_file(bpy::str filename, bpy::object globals = bpy::object(), b bpy::extract extr(var); \ if (extr.check()) { \ QObject *res = extr; \ - return res; \ + interfaceList.append(res); \ }\ } while (false) @@ -1289,7 +1289,7 @@ void PythonRunner::initPath(bpy::object &moduleNamespace) } -QObject *PythonRunner::instantiate(const QString &pluginName) +QList PythonRunner::instantiate(const QString &pluginName) { try { GILock lock; @@ -1303,11 +1303,12 @@ QObject *PythonRunner::instantiate(const QString &pluginName) std::string temp = ToString(pluginName); if (handled_exec_file(temp.c_str(), moduleNamespace)) { reportPythonError(); - return nullptr; + return QList(); } m_PythonObjects[pluginName] = moduleNamespace["createPlugin"](); bpy::object pluginObj = m_PythonObjects[pluginName]; + QList interfaceList; TRY_PLUGIN_TYPE(IPluginGame, pluginObj); // Must try the wrapper because it's only a plugin extension interface in C++, so doesn't extend QObject TRY_PLUGIN_TYPE(IPluginDiagnoseWrapper, pluginObj); @@ -1317,11 +1318,13 @@ QObject *PythonRunner::instantiate(const QString &pluginName) TRY_PLUGIN_TYPE(IPluginModPage, pluginObj); TRY_PLUGIN_TYPE(IPluginPreview, pluginObj); TRY_PLUGIN_TYPE(IPluginTool, pluginObj); + + return interfaceList; } catch (const bpy::error_already_set&) { qWarning("failed to run python script \"%s\"", qPrintable(pluginName)); reportPythonError(); } - return nullptr; + return QList(); } bool PythonRunner::isPythonInstalled() const diff --git a/src/runner/pythonrunner.h b/src/runner/pythonrunner.h index 4ef771a..ae5d620 100644 --- a/src/runner/pythonrunner.h +++ b/src/runner/pythonrunner.h @@ -10,7 +10,7 @@ class IPythonRunner { public: - virtual QObject *instantiate(const QString &pluginName) = 0; + virtual QList instantiate(const QString &pluginName) = 0; virtual bool isPythonInstalled() const = 0; virtual bool isPythonVersionSupported() const = 0; };