Skip to content

Commit ed69c3d

Browse files
usiemsjcfr
authored andcommitted
[Backport] Add enum values to the enum type object itself in any case...
...not just when it is a enum class in C++. It seems PySide does this too. (cherry picked from commit MeVisLab/pythonqt@d059d72)
1 parent fb6834f commit ed69c3d

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/PythonQtClassInfo.cpp

+6-13
Original file line numberDiff line numberDiff line change
@@ -870,26 +870,19 @@ PyObject* PythonQtClassInfo::findEnumWrapper(const QByteArray& name, PythonQtCla
870870
return enumWrapper;
871871
}
872872

873-
// required for the code below (for versions before Qt 6)
874-
Q_DECLARE_METATYPE(PythonQtObjectPtr)
875-
876873
void PythonQtClassInfo::createEnumWrappers(const QMetaObject* meta)
877874
{
878875
for (int i = meta->enumeratorOffset();i<meta->enumeratorCount();i++) {
879876
QMetaEnum e = meta->enumerator(i);
880877
PythonQtObjectPtr p;
881878
p.setNewRef(PythonQtPrivate::createNewPythonQtEnumWrapper(e.name(), _pythonQtClassWrapper));
882-
#if QT_VERSION > 0x050800
883-
if (e.isScoped()) {
884-
// add enum values to the enum type itself, in case enum value names are so generic
885-
// that they are not unique
886-
for (int j = 0; j < e.keyCount(); j++) {
887-
PythonQtObjectPtr enumValuePtr;
888-
enumValuePtr.setNewRef(PythonQtPrivate::createEnumValueInstance(p.object(), e.value(j)));
889-
p.addVariable(escapeReservedNames(e.key(j)), QVariant::fromValue(enumValuePtr));
890-
}
879+
// add enum values to the enum type itself, in case enum value names are so generic
880+
// that they are not unique
881+
for (int j = 0; j < e.keyCount(); j++) {
882+
PythonQtObjectPtr enumValuePtr;
883+
enumValuePtr.setNewRef(PythonQtPrivate::createEnumValueInstance(p.object(), e.value(j)));
884+
p.addVariable(escapeReservedNames(e.key(j)), enumValuePtr.toLocalVariant());
891885
}
892-
#endif
893886
_enumWrappers.append(p);
894887
}
895888
}

0 commit comments

Comments
 (0)