diff options
author | Christian Tismer <[email protected]> | 2021-01-05 18:50:49 +0100 |
---|---|---|
committer | Christian Tismer <[email protected]> | 2021-01-06 14:01:45 +0100 |
commit | b6d1b76b46d7b756f7cb01361037e1cb5efc990a (patch) | |
tree | 5f82399ecc57397c79e59caab286f690dbbcbe3c /sources/pyside6/libpyside | |
parent | b62040783613568901e76a26799e130632004a7e (diff) |
feature: Disable selection while creating a type
PySide 6 suddenly has problems with feature switching during
subtype initialization.
We introduce an enable function that can temporarily suppress
switching. This problem is solved so far.
It is the question whether this will break again in another
constellation. It might be considerable for the future to have
something like Python's PyType_Ready function.
Right now this is too much effort.
Change-Id: If0ed786d4761cf2356f01f7478e4a0d750e88d3c
Fixes: PYSIDE-1463
Pick-to: 6.0
Pick-to: 5.15
Reviewed-by: Cristian Maureira-Fredes <[email protected]>
Diffstat (limited to 'sources/pyside6/libpyside')
-rw-r--r-- | sources/pyside6/libpyside/feature_select.cpp | 10 | ||||
-rw-r--r-- | sources/pyside6/libpyside/feature_select.h | 1 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pyside.cpp | 5 |
3 files changed, 15 insertions, 1 deletions
diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp index 47a7472e1..b87751271 100644 --- a/sources/pyside6/libpyside/feature_select.cpp +++ b/sources/pyside6/libpyside/feature_select.cpp @@ -451,11 +451,11 @@ void finalize() } static bool patch_property_impl(); +static bool is_initialized = false; void init() { // This function can be called multiple times. - static bool is_initialized = false; if (!is_initialized) { fast_id_array = &_fast_id_array[1]; for (int idx = -1; idx < 256; ++idx) @@ -472,6 +472,14 @@ void init() cached_globals = nullptr; } +void Enable(bool enable) +{ + if (!is_initialized) + return; + featurePointer = enable ? featureProcArray : nullptr; + initSelectableFeature(enable ? SelectFeatureSet : nullptr); +} + ////////////////////////////////////////////////////////////////////////////// // // PYSIDE-1019: Support switchable extensions diff --git a/sources/pyside6/libpyside/feature_select.h b/sources/pyside6/libpyside/feature_select.h index 845828a4c..c7c14df3c 100644 --- a/sources/pyside6/libpyside/feature_select.h +++ b/sources/pyside6/libpyside/feature_select.h @@ -49,6 +49,7 @@ namespace Feature { PYSIDE_API void init(); PYSIDE_API void Select(PyObject *obj); PYSIDE_API PyObject *Select(PyTypeObject *type); +PYSIDE_API void Enable(bool); } // namespace Feature } // namespace PySide diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp index 7cc17f0c6..75b3eb16f 100644 --- a/sources/pyside6/libpyside/pyside.cpp +++ b/sources/pyside6/libpyside/pyside.cpp @@ -50,6 +50,7 @@ #include "pysidemetafunction_p.h" #include "pysidemetafunction.h" #include "dynamicqmetaobject.h" +#include "feature_select.h" #include <autodecref.h> #include <basewrapper.h> @@ -285,7 +286,11 @@ void initQObjectSubType(SbkObjectType *type, PyObject *args, PyObject * /* kwds qWarning("Sub class of QObject not inheriting QObject!? Crash will happen when using %s.", className.constData()); return; } + // PYSIDE-1463: Don't change feature selection durin subtype initialization. + // This behavior is observed with PySide 6. + PySide::Feature::Enable(false); initDynamicMetaObject(type, userData->mo.update(), userData->cppObjSize); + PySide::Feature::Enable(true); } void initQApp() |