aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/plugins/customwidgets.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-21 10:32:42 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-21 11:22:09 +0200
commitf2b61d1160e935083b14e7b26f4a21821d015e68 (patch)
treeb2bec583772236462839c9365aec479611136fcb /sources/pyside2/plugins/customwidgets.cpp
parent14023079a9c082fa85592858698810e997af418e (diff)
Brush up the code related to custom widgets in the QUiLoader module
- Modernize, use override, nullptr - Fix include conventions - Remove *Private structs. They don't make sense in a static plugin. - Add some explanatory comments - Add missing initializations of members - Most importantly: add error handling to PyCustomWidget::createWidget(), which so far would swallow all errors encountered when executing the Widget's __init__ function. Change-Id: I100a4239013f959c8fb0b0adc0d3a99f73bd4bff Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/plugins/customwidgets.cpp')
-rw-r--r--sources/pyside2/plugins/customwidgets.cpp34
1 files changed, 6 insertions, 28 deletions
diff --git a/sources/pyside2/plugins/customwidgets.cpp b/sources/pyside2/plugins/customwidgets.cpp
index e78dde206..28a2a6cf6 100644
--- a/sources/pyside2/plugins/customwidgets.cpp
+++ b/sources/pyside2/plugins/customwidgets.cpp
@@ -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.
@@ -37,47 +37,25 @@
**
****************************************************************************/
-#include "customwidget.h"
#include "customwidgets.h"
-
-
-struct PyCustomWidgetPrivate
-{
- PyObject *pyObject;
- bool initialized;
-};
-
-struct PyCustomWidgetsPrivate
-{
- QList<QDesignerCustomWidgetInterface *> widgets;
- ~PyCustomWidgetsPrivate();
-};
-
-
-PyCustomWidgetsPrivate::~PyCustomWidgetsPrivate()
-{
- qDeleteAll(widgets);
- widgets.clear();
-}
+#include "customwidget.h"
PyCustomWidgets::PyCustomWidgets(QObject *parent)
- : QObject(parent), m_data(new PyCustomWidgetsPrivate)
+ : QObject(parent)
{
}
PyCustomWidgets::~PyCustomWidgets()
{
- delete m_data;
+ qDeleteAll(m_widgets);
}
void PyCustomWidgets::registerWidgetType(PyObject *widget)
{
- m_data->widgets.append(new PyCustomWidget(widget));
+ m_widgets.append(new PyCustomWidget(widget));
}
QList<QDesignerCustomWidgetInterface *> PyCustomWidgets::customWidgets() const
{
- return m_data->widgets;
+ return m_widgets;
}
-
-