Gui: Prevent UiLoader from loading 3rd-party Qt plugins.

Due to a flaw in the QUiLoader, UiLoader were loading all designer plugins
it can find in QApplication::libraryPaths(). This in general a bad
practice and leads to bugs due to some plugins may perform some unexpected
actions upon load which may interfere with FreeCAD's functionality.

To avoid such problems reset the libraryPaths before creation of a
UiLoader object.

Also move setLanguageChangeEnabled(true) into constructor due to it's
called every time it's being instanced anyway.

See: https://github.com/FreeCAD/FreeCAD/issues/8708
This commit is contained in:
Alexander Golubev
2023-03-10 04:59:45 +03:00
committed by wwmayer
parent 64eb85b1ea
commit 992dec2c6b
5 changed files with 56 additions and 27 deletions

View File

@@ -544,8 +544,7 @@ TaskDialogPython::~TaskDialogPython()
bool TaskDialogPython::tryLoadUiFile()
{
if (dlg.hasAttr(std::string("ui"))) {
UiLoader loader;
loader.setLanguageChangeEnabled(true);
auto loader = UiLoader::newInstance();
QString fn, icon;
Py::String ui(dlg.getAttr(std::string("ui")));
std::string path = static_cast<std::string>(ui);
@@ -554,7 +553,7 @@ bool TaskDialogPython::tryLoadUiFile()
QFile file(fn);
QWidget* form = nullptr;
if (file.open(QFile::ReadOnly))
form = loader.load(&file, nullptr);
form = loader->load(&file, nullptr);
file.close();
if (form) {
appendForm(form, QPixmap(icon));