Problem loading Qt Designer plugins from different directories

Ivan Sinkarenko ivan.sinkarenko at cern.ch
Thu Aug 20 15:25:43 BST 2020


Hi Phil,

I've found a bug in libpyqt5.so loader, namely inside 
designer/pluginloader.cpp.

1. Consider having 2 plugins in separate directories: 
/path/to/first/my_plugin.py; /path/to/second/my_plugin.py, and loading 
that into Qt Designer simultaneously, e.g. 
PYQTDESIGNERPATH=/path/to/first:/path/to/second
2. PyCustomWidgets::importPlugins function will be called twice with 
arguments ("/path/to/first", "my_plugin") and ("/path/to/second", 
"my_plugin").
3. The first argument (paths) are added to sys.modules
4. The second argument is given to PyImport_ImportModule. But because 
both are named "my_plugin", only the first plugin will be loaded. The 
second time it will skip import, as Python always does to modules.
5. In Qt Designer, you will find 2 entries of the same plugin under 
Help->"About Plugins".

Not too critical (as can be circumvented by always having unique 
filenames), but was quite unexpected to find.


Cheers,
Ivan


More information about the PyQt mailing list