aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/QtUiTools/glue/plugins.h
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/PySide2/QtUiTools/glue/plugins.h')
-rw-r--r--sources/pyside2/PySide2/QtUiTools/glue/plugins.h32
1 files changed, 17 insertions, 15 deletions
diff --git a/sources/pyside2/PySide2/QtUiTools/glue/plugins.h b/sources/pyside2/PySide2/QtUiTools/glue/plugins.h
index 9bfcec6ea..402965a81 100644
--- a/sources/pyside2/PySide2/QtUiTools/glue/plugins.h
+++ b/sources/pyside2/PySide2/QtUiTools/glue/plugins.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt for Python.
@@ -40,26 +40,28 @@
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
-#include <QPluginLoader>
#include "customwidgets.h"
-inline void registerCustomWidget(PyObject *obj)
-{
- static PyCustomWidgets *plugin = nullptr;
+#include <QtCore/qpluginloader.h>
- if (plugin == 0) {
- const auto &instances = QPluginLoader::staticInstances();
- for (QObject *o : instances) {
- plugin = qobject_cast<PyCustomWidgets *>(o);
- if (plugin)
- break;
- }
+static inline PyCustomWidgets *findPlugin()
+{
+ const auto &instances = QPluginLoader::staticInstances();
+ for (QObject *o : instances) {
+ if (auto plugin = qobject_cast<PyCustomWidgets *>(o))
+ return plugin;
}
+ return nullptr;
+}
- if (!plugin)
- qDebug() << "Failed to load uiloader plugin.";
- else
+static void registerCustomWidget(PyObject *obj)
+{
+ static PyCustomWidgets *const plugin = findPlugin();
+
+ if (plugin)
plugin->registerWidgetType(obj);
+ else
+ qWarning("Qt for Python: Failed to find the static QUiLoader plugin.");
}
#endif