aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2025-11-21 08:36:07 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2025-11-25 11:48:23 +0100
commit8e969657c834e600fbabad9f4e85c768ddd361de (patch)
treea81f85e46cdb930e0ceaad29a2945a61362f5546
parent0880d5799c689ab3f1cea599ba215fd0900d3b73 (diff)
Enum forgiveness mode: Move option checks up
In lookupUnqualifiedOrOldEnum(), move the option checks up so that the function does unnecessarily loop over the MRO to resolve enumerations when they are disabled. Task-number: PYSIDE-1735 Change-Id: Ifc5c869b21e2f1d291784beaf192e8e328f4966b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken6/libshiboken/sbkfeature_base.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.cpp b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
index a705cdb40..fc29442ce 100644
--- a/sources/shiboken6/libshiboken/sbkfeature_base.cpp
+++ b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
@@ -269,6 +269,11 @@ static PyObject *lookupUnqualifiedOrOldEnum(PyTypeObject *type, PyObject *name)
// MRO has been observed to be 0 in case of errors with QML decorators
if (type == nullptr || type->tp_mro == nullptr)
return nullptr;
+ // Quick Check: Disabled?
+ const bool useFakeRenames = (Enum::enumOption & Enum::ENOPT_NO_FAKERENAMES) == 0;
+ const bool useFakeShortcuts = (Enum::enumOption & Enum::ENOPT_NO_FAKESHORTCUT) == 0;
+ if (!useFakeRenames && !useFakeShortcuts)
+ return nullptr;
// Quick Check: Avoid "__..", "_slots", etc.
if (std::isalpha(Shiboken::String::toCString(name)[0]) == 0)
return nullptr;
@@ -291,7 +296,6 @@ static PyObject *lookupUnqualifiedOrOldEnum(PyTypeObject *type, PyObject *name)
continue;
if (!sotp->enumFlagsDict)
initEnumFlagsDict(type_base);
- bool useFakeRenames = !(Enum::enumOption & Enum::ENOPT_NO_FAKERENAMES);
if (useFakeRenames) {
auto *rename = PyDict_GetItem(sotp->enumFlagsDict, name);
if (rename) {
@@ -322,7 +326,6 @@ static PyObject *lookupUnqualifiedOrOldEnum(PyTypeObject *type, PyObject *name)
return flagType;
}
}
- bool useFakeShortcuts = !(Enum::enumOption & Enum::ENOPT_NO_FAKESHORTCUT);
if (useFakeShortcuts) {
AutoDecRef tpDict(PepType_GetDict(type_base));
auto *dict = tpDict.object();