Skip to content

Commit ecbd05c

Browse files
committed
Prevent invalid plugin dir from creating problems
In `PythonPluginManager::loadPluginsFrom`, a import of pycc_runtime was done to get the subclasses of the plugins base class. However that import can only work if pycc had already been imported before as pycc contains definitions necessary for pycc_runtime to function. And plugins needs to import pycc to be able to subclass So if no plugins were imported (either because of invalid path or empty folders) the pycc_runtime import would fail, and subsequent import of pycc_runtime would also fail making the runtime useless as no interaction with the main app was possible The fix is to import pycc intead as pycc will import pycc_runtime
1 parent f581ee4 commit ecbd05c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/PythonPluginManager.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ void PythonPluginManager::loadPluginsFrom(const QStringList &paths)
107107
py::object appendToPythonSysPath = py::module::import("sys").attr("path").attr("append");
108108
for (const QString &path : paths)
109109
{
110+
if (!QDir(path).exists())
111+
{
112+
plgWarning() << path << " does not exists";
113+
continue;
114+
}
115+
110116
plgPrint() << "Searching in " << path;
111117
appendToPythonSysPath(path);
112118
QDirIterator iter(path);
@@ -142,7 +148,7 @@ void PythonPluginManager::loadPluginsFrom(const QStringList &paths)
142148
}
143149

144150
py::list subClassTypes =
145-
py::module::import("pycc_runtime").attr("PythonPluginInterface").attr("__subclasses__")();
151+
py::module::import("pycc").attr("PythonPluginInterface").attr("__subclasses__")();
146152
for (auto &subClassType : subClassTypes)
147153
{
148154
QString pluginName;

0 commit comments

Comments
 (0)