diff options
Diffstat (limited to 'sources/pyside6/libpysideqml/pysideqmllistproperty.cpp')
-rw-r--r-- | sources/pyside6/libpysideqml/pysideqmllistproperty.cpp | 109 |
1 files changed, 51 insertions, 58 deletions
diff --git a/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp b/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp index 47c33b3e2..75bb5af96 100644 --- a/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp +++ b/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp @@ -1,46 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt for Python. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "pysideqmllistproperty_p.h" #include "pysideqmlregistertype_p.h" #include <shiboken.h> +#include <pep384ext.h> #include <signature.h> #include <pysideproperty.h> @@ -69,30 +34,51 @@ extern "C" static PyObject *propList_tp_new(PyTypeObject *subtype, PyObject * /* args */, PyObject * /* kwds */) { - PySideProperty *me = reinterpret_cast<PySideProperty *>(subtype->tp_alloc(subtype, 0)); + auto *me = PepExt_TypeCallAlloc<PySideProperty>(subtype, 0); me->d = new QmlListPropertyPrivate; return reinterpret_cast<PyObject *>(me); } static int propListTpInit(PyObject *self, PyObject *args, PyObject *kwds) { - static const char *kwlist[] = {"type", "append", "count", "at", "clear", "replace", "removeLast", 0}; + static const char *kwlist[] = {"type", "append", "count", "at", "clear", + "replace", "removeLast", + "doc", "notify", // PySideProperty + "designable", "scriptable", "stored", + "user", "constant", "final", + nullptr}; PySideProperty *pySelf = reinterpret_cast<PySideProperty *>(self); auto *data = static_cast<QmlListPropertyPrivate *>(pySelf->d); + char *doc{}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O|OOOOOO:QtQml.ListProperty", (char **) kwlist, + "O|OOOOOOsObbbbbb:QtQml.ListProperty", + const_cast<char **>(kwlist), &data->type, &data->append, &data->count, &data->at, &data->clear, &data->replace, - &data->removeLast)) { + &data->removeLast, + /*s*/ &doc, + /*O*/ &(data->notify), // PySideProperty + /*bbb*/ &(data->designable), + &(data->scriptable), + &(data->stored), + /*bbb*/ &(data->user), + &(data->constant), + &(data->final))) { return -1; } + if (doc) + data->doc = doc; + else + data->doc.clear(); + PyTypeObject *qobjectType = qObjectType(); if (!PySequence_Contains(data->type->tp_mro, reinterpret_cast<PyObject *>(qobjectType))) { @@ -116,24 +102,31 @@ static int propListTpInit(PyObject *self, PyObject *args, PyObject *kwds) return 0; } -static PyType_Slot PropertyListType_slots[] = { - {Py_tp_new, reinterpret_cast<void *>(propList_tp_new)}, - {Py_tp_init, reinterpret_cast<void *>(propListTpInit)}, - {0, nullptr} -}; -static PyType_Spec PropertyListType_spec = { - "2:PySide6.QtQml.ListProperty", - sizeof(PySideProperty), - 0, - Py_TPFLAGS_DEFAULT, - PropertyListType_slots, -}; - +static PyTypeObject *createPropertyListType() +{ + PyType_Slot PropertyListType_slots[] = { + {Py_tp_new, reinterpret_cast<void *>(propList_tp_new)}, + {Py_tp_init, reinterpret_cast<void *>(propListTpInit)}, + {0, nullptr} + }; + + PyType_Spec PropertyListType_spec = { + "2:PySide6.QtQml.ListProperty", + sizeof(PySideProperty), + 0, + Py_TPFLAGS_DEFAULT, + PropertyListType_slots, + }; + + Shiboken::AutoDecRef bases(Py_BuildValue("(O)", PySideProperty_TypeF())); + return SbkType_FromSpecWithBases(&PropertyListType_spec, bases.object()); +} PyTypeObject *PropertyList_TypeF(void) { - static Shiboken::AutoDecRef bases(Py_BuildValue("(O)", PySideProperty_TypeF())); - static auto *type = SbkType_FromSpecWithBases(&PropertyListType_spec, bases); + // PYSIDE-2230: This was a wrong replacement by static AutoDecref. + // Never do that, deletes things way too late. + static PyTypeObject *type = createPropertyListType(); return type; } @@ -176,7 +169,7 @@ qsizetype propListCount(QQmlListProperty<QObject> *propList) return 0; } - int cppResult = 0; + qsizetype cppResult = 0; auto *converter = Shiboken::Conversions::PrimitiveTypeConverter<qsizetype>(); if (auto *pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(converter, retVal)) pythonToCpp(retVal, &cppResult); |