diff options
Diffstat (limited to 'sources/pyside2')
-rw-r--r-- | sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp | 30 | ||||
-rw-r--r-- | sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h | 8 | ||||
-rw-r--r-- | sources/pyside2/PySide2/QtQml/typesystem_qml.xml | 11 |
3 files changed, 26 insertions, 23 deletions
diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp index 4218678bf..5af6abb47 100644 --- a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp +++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.cpp @@ -365,18 +365,23 @@ QtQml_VolatileBoolObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds) QtQml_VolatileBoolObject *self = reinterpret_cast<QtQml_VolatileBoolObject *>(type->tp_alloc(type, 0)); - if (self != Q_NULLPTR) - self->flag = ok; + if (self != nullptr) + self->flag = new AtomicBool(ok); return reinterpret_cast<PyObject *>(self); } +static void QtQml_VolatileBoolObject_dealloc(PyObject *self) +{ + auto volatileBool = reinterpret_cast<QtQml_VolatileBoolObject *>(self); + delete volatileBool->flag; + Sbk_object_dealloc(self); +} + static PyObject * QtQml_VolatileBoolObject_get(QtQml_VolatileBoolObject *self) { - if (self->flag) - return Py_True; - return Py_False; + return *self->flag ? Py_True : Py_False; } static PyObject * @@ -395,10 +400,7 @@ QtQml_VolatileBoolObject_set(QtQml_VolatileBoolObject *self, PyObject *args) return Q_NULLPTR; } - if (ok > 0) - self->flag = true; - else - self->flag = false; + *self->flag = ok > 0; Py_RETURN_NONE; } @@ -418,7 +420,7 @@ QtQml_VolatileBoolObject_repr(QtQml_VolatileBoolObject *self) { PyObject *s; - if (self->flag) + if (*self->flag) s = PyBytes_FromFormat("%s(True)", Py_TYPE(self)->tp_name); else @@ -433,12 +435,12 @@ QtQml_VolatileBoolObject_str(QtQml_VolatileBoolObject *self) { PyObject *s; - if (self->flag) + if (*self->flag) s = PyBytes_FromFormat("%s(True) -> %p", - Py_TYPE(self)->tp_name, &(self->flag)); + Py_TYPE(self)->tp_name, self->flag); else s = PyBytes_FromFormat("%s(False) -> %p", - Py_TYPE(self)->tp_name, &(self->flag)); + Py_TYPE(self)->tp_name, self->flag); Py_XINCREF(s); return s; } @@ -448,7 +450,7 @@ static PyType_Slot QtQml_VolatileBoolType_slots[] = { {Py_tp_str, (void *)reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_str)}, {Py_tp_methods, (void *)QtQml_VolatileBoolObject_methods}, {Py_tp_new, (void *)QtQml_VolatileBoolObject_new}, - {Py_tp_dealloc, (void *)Sbk_object_dealloc}, + {Py_tp_dealloc, (void *)QtQml_VolatileBoolObject_dealloc}, {0, 0} }; static PyType_Spec QtQml_VolatileBoolType_spec = { diff --git a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h index e94ea043f..74690d937 100644 --- a/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h +++ b/sources/pyside2/PySide2/QtQml/pysideqmlregistertype.h @@ -42,6 +42,8 @@ #include <sbkpython.h> +#include <atomic> + struct SbkObjectType; namespace PySide @@ -71,11 +73,13 @@ int qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int vers const char *qmlName); } -// Volatile Bool Ptr type definition. +// Volatile Bool Ptr type definition for QQmlIncubationController::incubateWhile(std::atomic<bool> *, int) + +using AtomicBool = std::atomic<bool>; typedef struct { PyObject_HEAD - volatile bool flag; + AtomicBool *flag; } QtQml_VolatileBoolObject; PyAPI_FUNC(PyTypeObject *) QtQml_VolatileBoolTypeF(void); diff --git a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml index 4ebc4b417..af6f75131 100644 --- a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml +++ b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml @@ -59,12 +59,11 @@ <!-- For qmlEngine(const QObject*), qmlContext(const QObject*) in qqml.h --> <namespace-type name="QtQml"/> - <!-- FIXME Qt 6: expose QQmlIncubationController::incubateWhile() - (see QtQml_VolatileBoolTypeF in pysideqmlregistertype.h) + <!-- expose QQmlIncubationController::incubateWhile() (see + QtQml_VolatileBoolTypeF/pysideqmlregistertype.h) --> <namespace-type name="std" generate="no"> <value-type name="atomic" generate="no"/> </namespace-type> - --> <add-function signature="qmlRegisterType(PyTypeObject,const char*,int,int,const char*)" return-type="int"> <inject-documentation format="target" mode="append"> @@ -162,19 +161,17 @@ <enum-type name="Status"/> </object-type> <object-type name="QQmlIncubationController"> - <!-- FIXME Qt 6 <modify-function signature="incubateWhile(std::atomic<bool>*,int)" allow-thread="yes"> <modify-argument index="1"> The replace type is needed to use the VolatileBool_Check macro instead of a template conversion function with "volatile bool" as argument. <replace-type modified-type="VolatileBool"/> <conversion-rule class="native"> - volatile bool * %out = - &((reinterpret_cast<QtQml_VolatileBoolObject *>(%PYARG_1))->flag); + auto volatileBool = reinterpret_cast<QtQml_VolatileBoolObject *>(%PYARG_1); + std::atomic<bool> *%out = volatileBool->flag; </conversion-rule> </modify-argument> </modify-function> - --> </object-type> <!-- TODO: QQmlListProperty is a template class, and thus should probably be treated like a |