@@ -205,46 +205,53 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con
205205 }
206206
207207 tail = findDecoratorSlots (memberName, memberNameLen, tail, found, memberCache, upcastingOffset);
208-
209- return tail;
210- }
211208
212- bool PythonQtClassInfo::lookForMethodAndCache (const char * memberName)
213- {
214- bool found = false ;
215- int memberNameLen = static_cast <int >(strlen (memberName));
216- PythonQtSlotInfo* tail = NULL ;
209+ // now look for slots/signals/methods on this level of the meta object
217210 if (_meta) {
218211 int numMethods = _meta->methodCount ();
219- for (int i = 0 ; i < numMethods; i++) {
212+ // start from methodOffset, to only add slots which are located in this class,
213+ // and not in the parent class, which is traversed recursively later on.
214+ // (if the class in not a QObject, we are working with a script wrapper QObject
215+ // and need to read all slots/signals starting from 0).
216+ int methodOffset = _isQObject?_meta->methodOffset ():0 ;
217+ for (int i = methodOffset; i < numMethods; i++) {
220218 QMetaMethod m = _meta->method (i);
221219 if (((m.methodType () == QMetaMethod::Method ||
222- m.methodType () == QMetaMethod::Slot) && m.access () == QMetaMethod::Public)
220+ m.methodType () == QMetaMethod::Slot) && m.access () == QMetaMethod::Public)
223221 || m.methodType ()==QMetaMethod::Signal) {
224-
225- const char * sigStart = m.signature ();
226- // find the first '('
227- int offset = findCharOffset (sigStart, ' (' );
228-
229- // check if same length and same name
230- if (memberNameLen == offset && qstrncmp (memberName, sigStart, offset)==0 ) {
231- found = true ;
232- PythonQtSlotInfo* info = new PythonQtSlotInfo (this , m, i);
233- if (tail) {
234- tail->setNextInfo (info);
235- } else {
236- PythonQtMemberInfo newInfo (info);
237- _cachedMembers.insert (memberName, newInfo);
222+
223+ const char * sigStart = m.signature ();
224+ // find the first '('
225+ int offset = findCharOffset (sigStart, ' (' );
226+
227+ // check if same length and same name
228+ if (memberNameLen == offset && qstrncmp (memberName, sigStart, offset)==0 ) {
229+ found = true ;
230+ PythonQtSlotInfo* info = new PythonQtSlotInfo (this , m, i);
231+ if (tail) {
232+ tail->setNextInfo (info);
233+ } else {
234+ PythonQtMemberInfo newInfo (info);
235+ memberCache.insert (memberName, newInfo);
236+ }
237+ tail = info;
238238 }
239- tail = info;
240- }
241239 }
242240 }
243241 }
242+ return tail;
243+ }
244+
245+ bool PythonQtClassInfo::lookForMethodAndCache (const char * memberName)
246+ {
247+ bool found = false ;
248+ PythonQtSlotInfo* tail = NULL ;
244249
245250 // look for dynamic decorators in this class and in derived classes
251+ // (do this first to allow overloading of existing slots with generated wrappers,
252+ // e.g. QDialog::accept is overloaded with PythonQtWrapper_QDialog::accept decorator)
246253 tail = recursiveFindDecoratorSlotsFromDecoratorProvider (memberName, tail, found, _cachedMembers, 0 );
247-
254+
248255 return found;
249256}
250257
@@ -710,22 +717,6 @@ QObject* PythonQtClassInfo::decorator()
710717 return _decoratorProvider;
711718}
712719
713- bool PythonQtClassInfo::hasOwnerMethodButNoOwner (void * object)
714- {
715- PythonQtMemberInfo info = member (" py_hasOwner" );
716- if (info._type == PythonQtMemberInfo::Slot) {
717- void * obj = object;
718- bool result = false ;
719- void * args[2 ];
720- args[0 ] = &result;
721- args[1 ] = &obj;
722- info._slot ->decorator ()->qt_metacall (QMetaObject::InvokeMetaMethod, info._slot ->slotIndex (), args);
723- return !result;
724- } else {
725- return false ;
726- }
727- }
728-
729720void * PythonQtClassInfo::recursiveCastDownIfPossible (void * ptr, const char ** resultClassName)
730721{
731722 if (!_polymorphicHandlers.isEmpty ()) {
0 commit comments