@@ -251,6 +251,9 @@ bool PythonQtClassInfo::lookForEnumAndCache(const QMetaObject* meta, const char*
251251 int enumCount = meta->enumeratorCount ();
252252 for (int i=0 ;i<enumCount; i++) {
253253 QMetaEnum e = meta->enumerator (i);
254+ // we do not want flags, they will cause our values to appear two times
255+ if (e.isFlag ()) continue ;
256+
254257 for (int j=0 ; j < e.keyCount (); j++) {
255258 if (qstrcmp (e.key (j), memberName)==0 ) {
256259 PyObject* enumType = findEnumWrapper (e.name ());
@@ -490,6 +493,9 @@ QStringList PythonQtClassInfo::memberList(bool metaOnly)
490493 for (int i = 0 ; i<meta->enumeratorCount (); i++) {
491494 QMetaEnum e = meta->enumerator (i);
492495 l << e.name ();
496+ // we do not want flags, they will cause our values to appear two times
497+ if (e.isFlag ()) continue ;
498+
493499 for (int j=0 ; j < e.keyCount (); j++) {
494500 l << QString (e.key (j));
495501 }
@@ -750,46 +756,27 @@ void* PythonQtClassInfo::castDownIfPossible(void* ptr, PythonQtClassInfo** resul
750756 return resultPtr;
751757}
752758
753- bool PythonQtClassInfo::hasEnum (const QByteArray& name, PythonQtClassInfo* localScope)
759+ PyObject* PythonQtClassInfo::findEnumWrapper (const QByteArray& name, PythonQtClassInfo* localScope, bool & isLocalEnum )
754760{
761+ isLocalEnum = true ;
755762 int scopePos = name.lastIndexOf (" ::" );
756763 if (scopePos != -1 ) {
764+ isLocalEnum = false ;
757765 // slit into scope and enum name
758766 QByteArray enumScope = name.mid (0 ,scopePos);
759767 QByteArray enumName = name.mid (scopePos+2 );
760768 PythonQtClassInfo* info = PythonQt::priv ()->getClassInfo (enumScope);
761769 if (info) {
762- return info->hasEnum (enumName);
770+ return info->findEnumWrapper (enumName);
763771 } else {
764- return false ;
772+ return NULL ;
765773 }
766774 }
767775 if (localScope) {
768- return localScope->hasEnum (name);
776+ return localScope->findEnumWrapper (name);
769777 } else {
770- return false ;
771- }
772- }
773-
774- bool PythonQtClassInfo::hasEnum (const QByteArray& name)
775- {
776- bool found = false ;
777- if (_meta) {
778- found = _meta->indexOfEnumerator (name)!=-1 ;
779- }
780- if (!found) {
781- // check enums in the class hierachy of CPP classes
782- // look for dynamic decorators in this class and in derived classes
783- QList<QObject*> decoObjects;
784- recursiveCollectDecoratorObjects (decoObjects);
785- foreach (QObject* deco, decoObjects) {
786- found = deco->metaObject ()->indexOfEnumerator (name)!=-1 ;
787- if (found) {
788- break ;
789- }
790- }
778+ return NULL ;
791779 }
792- return found;
793780}
794781
795782void PythonQtClassInfo::createEnumWrappers (const QMetaObject* meta)
0 commit comments