From d794b7a748b82daa1af2a32b4c6a02d12d7626dc Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sun, 15 Jul 2018 15:43:10 +0200 Subject: Generate fully Qualified Names for Flags The flags structure should give correct full names. See the doc in the issue tracker. Task-number: PYSIDE-747 Change-Id: I6b5c602566d3e4b8a2a93e2522e92da956578b18 Reviewed-by: Friedemann Kleint --- sources/pyside2/libpyside/pysideqflags.cpp | 4 ++-- sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sources/pyside2/libpyside/pysideqflags.cpp b/sources/pyside2/libpyside/pysideqflags.cpp index 11db70bb5..f4263403b 100644 --- a/sources/pyside2/libpyside/pysideqflags.cpp +++ b/sources/pyside2/libpyside/pysideqflags.cpp @@ -165,8 +165,8 @@ namespace QFlags PyTypeObject *create(const char* name, PyType_Slot numberMethods[]) { char qualname[200]; - strcpy(qualname, "PySide2.libpyside."); - strcat(qualname, name); + // PYSIDE-747: Here we insert now the full class name. + strcpy(qualname, name); // Careful: PyType_FromSpec does not allocate the string. PyType_Spec *newspec = new PyType_Spec; newspec->name = strdup(qualname); diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 568b5fd27..a9556fa4c 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -4483,8 +4483,13 @@ void CppGenerator::writeEnumInitialization(QTextStream& s, const AbstractMetaEnu if (!cppEnum->isAnonymous()) { FlagsTypeEntry* flags = enumTypeEntry->flags(); if (flags) { - s << INDENT << cpythonTypeNameExt(flags) << " = PySide::QFlags::create(\"" << flags->flagsName() << "\", " - << cpythonEnumName(cppEnum) << "_number_slots);" << endl; + // The following could probably be made nicer: + // We need 'flags->flagsName()' with the full module/class path. + QString fullPath = getClassTargetFullName(cppEnum); + fullPath.truncate(fullPath.lastIndexOf(QLatin1Char('.')) + 1); + s << INDENT << cpythonTypeNameExt(flags) << " = PySide::QFlags::create(\"" + << fullPath << flags->flagsName() << "\", " + << cpythonEnumName(cppEnum) << "_number_slots);" << endl; } enumVarTypeObj = cpythonTypeNameExt(enumTypeEntry); -- cgit v1.2.3