aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpyside/feature_select.cpp
diff options
context:
space:
mode:
authorChristian Tismer <[email protected]>2022-11-21 12:06:18 +0100
committerChristian Tismer <[email protected]>2022-11-29 17:57:32 +0100
commit916bae507f76f4f063af81439f17cf11c914b4bd (patch)
treecfb25fbff65534d4610c5cae9733622828977c76 /sources/pyside6/libpyside/feature_select.cpp
parentc199b64bcbcaeb55ce78ce3f4e772fcdc68073f4 (diff)
__feature__: Cleanup before reworking the context switching
Some small changes: - Reserved bits are now signed - old comments were no more true - SelectFeatureSet simplified Task-number: PYSIDE-2029 Change-Id: Id8d83de4278bd4e618f5c601f9fa3c25ac172d53 Pick-to: 6.4 Reviewed-by: Shyamnath Premnadh <[email protected]> Reviewed-by: Friedemann Kleint <[email protected]>
Diffstat (limited to 'sources/pyside6/libpyside/feature_select.cpp')
-rw-r--r--sources/pyside6/libpyside/feature_select.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp
index cf55ae7cf..b3117d40d 100644
--- a/sources/pyside6/libpyside/feature_select.cpp
+++ b/sources/pyside6/libpyside/feature_select.cpp
@@ -155,7 +155,7 @@ static inline PyObject *getSelectId(PyObject *dict)
static inline void setCurrentSelectId(PyTypeObject *type, PyObject *select_id)
{
- SbkObjectType_SetReserved(type, PyLong_AsSsize_t(select_id)); // int/long cheating
+ SbkObjectType_SetReserved(type, PyLong_AsSsize_t(select_id));
}
static inline void setCurrentSelectId(PyTypeObject *type, int id)
@@ -267,7 +267,7 @@ static bool createNewFeatureSet(PyTypeObject *type, PyObject *select_id)
Py_INCREF(prev_dict); // keep the first ref unchanged
if (!addNewDict(type, select_id))
return false;
- auto id = PyLong_AsSsize_t(select_id); // int/long cheating
+ auto id = PyLong_AsSsize_t(select_id);
if (id == -1)
return false;
setCurrentSelectId(type, id);
@@ -313,7 +313,7 @@ static bool SelectFeatureSetSubtype(PyTypeObject *type, PyObject *select_id)
return true;
}
-static inline PyObject *SelectFeatureSet(PyTypeObject *type)
+static inline void SelectFeatureSet(PyTypeObject *type)
{
/*
* This is the main function of the module.
@@ -325,8 +325,10 @@ static inline PyObject *SelectFeatureSet(PyTypeObject *type)
*/
if (Py_TYPE(type->tp_dict) == Py_TYPE(PyType_Type.tp_dict)) {
// We initialize the dynamic features by using our own dict type.
- if (!replaceClassDict(type))
- return nullptr;
+ if (!replaceClassDict(type)) {
+ Py_FatalError("failed to replace class dict!");
+ return;
+ }
}
PyObject *select_id = getFeatureSelectId(); // borrowed
PyObject *current_id = getCurrentSelectId(type); // borrowed
@@ -349,7 +351,7 @@ static inline PyObject *SelectFeatureSet(PyTypeObject *type)
// PYSIDE-1436: Clear all caches for the type and subtypes.
PyType_Modified(type);
}
- return type->tp_dict;
+ return;
}
// For cppgenerator:
@@ -358,14 +360,13 @@ void Select(PyObject *obj)
if (featurePointer == nullptr)
return;
auto type = Py_TYPE(obj);
- type->tp_dict = SelectFeatureSet(type);
+ SelectFeatureSet(type);
}
-PyObject *Select(PyTypeObject *type)
+void Select(PyTypeObject *type)
{
if (featurePointer != nullptr)
- type->tp_dict = SelectFeatureSet(type);
- return type->tp_dict;
+ SelectFeatureSet(type);
}
static bool feature_01_addLowerNames(PyTypeObject *type, PyObject *prev_dict, int id);