@@ -159,7 +159,6 @@ PythonQtSlotInfo* PythonQtClassInfo::recursiveFindDecoratorSlotsFromDecoratorPro
159159
160160PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider (const char * memberName, PythonQtSlotInfo* tail, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset) {
161161 QObject* decoratorProvider = decorator ();
162- int memberNameLen = static_cast <int >(strlen (memberName));
163162 if (decoratorProvider) {
164163 // qDebug()<< "looking " << decoratorProvider->metaObject()->className() << " " << memberName << " " << upcastingOffset;
165164 const QMetaObject* meta = decoratorProvider->metaObject ();
@@ -170,24 +169,21 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con
170169 if ((m.methodType () == QMetaMethod::Method ||
171170 m.methodType () == QMetaMethod::Slot) && m.access () == QMetaMethod::Public) {
172171
173- const char * sigStart = m. signature ( );
172+ QByteArray signature = PythonQtUtils::methodName (m );
174173 bool isClassDeco = false ;
175- if (qstrncmp (sigStart, " static_" , 7 )== 0 ) {
174+ if (signature. startsWith ( " static_" ) ) {
176175 // skip the static_classname_ part of the string
177- sigStart += 7 + 1 + strlen (className ());
176+ signature = signature. mid ( 7 + 1 + strlen (className () ));
178177 isClassDeco = true ;
179- } else if (qstrncmp (sigStart, " new_" , 4 )== 0 ) {
178+ } else if (signature. startsWith ( " new_" ) ) {
180179 isClassDeco = true ;
181- } else if (qstrncmp (sigStart, " delete_" , 7 )== 0 ) {
180+ } else if (signature. startsWith ( " delete_" ) ) {
182181 isClassDeco = true ;
183182 }
184- // find the first '('
185- int offset = findCharOffset (sigStart, ' (' );
186-
187183 // XXX no checking is currently done if the slots have correct first argument or not...
188184
189185 // check if same length and same name
190- if (memberNameLen == offset && qstrncmp ( memberName, sigStart, offset)== 0 ) {
186+ if (signature == memberName) {
191187 found = true ;
192188 PythonQtSlotInfo* info = new PythonQtSlotInfo (this , m, i, decoratorProvider, isClassDeco?PythonQtSlotInfo::ClassDecorator:PythonQtSlotInfo::InstanceDecorator);
193189 info->setUpcastingOffset (upcastingOffset);
@@ -196,15 +192,15 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con
196192 tail->setNextInfo (info);
197193 } else {
198194 PythonQtMemberInfo newInfo (info);
199- memberCache.insert (memberName , newInfo);
195+ memberCache.insert (signature , newInfo);
200196 }
201197 tail = info;
202198 }
203199 }
204200 }
205201 }
206202
207- tail = findDecoratorSlots (memberName, memberNameLen, tail, found, memberCache, upcastingOffset);
203+ tail = findDecoratorSlots (memberName, tail, found, memberCache, upcastingOffset);
208204
209205 // now look for slots/signals/methods on this level of the meta object
210206 if (_meta) {
@@ -220,19 +216,17 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con
220216 m.methodType () == QMetaMethod::Slot) && m.access () == QMetaMethod::Public)
221217 || m.methodType ()==QMetaMethod::Signal) {
222218
223- const char * sigStart = m.signature ();
224- // find the first '('
225- int offset = findCharOffset (sigStart, ' (' );
219+ QByteArray signature = PythonQtUtils::methodName (m);
226220
227221 // check if same length and same name
228- if (memberNameLen == offset && qstrncmp ( memberName, sigStart, offset)== 0 ) {
222+ if (signature == memberName) {
229223 found = true ;
230224 PythonQtSlotInfo* info = new PythonQtSlotInfo (this , m, i);
231225 if (tail) {
232226 tail->setNextInfo (info);
233227 } else {
234228 PythonQtMemberInfo newInfo (info);
235- memberCache.insert (memberName , newInfo);
229+ memberCache.insert (signature , newInfo);
236230 }
237231 tail = info;
238232 }
@@ -369,20 +363,18 @@ void PythonQtClassInfo::recursiveCollectClassInfos(QList<PythonQtClassInfo*>& cl
369363 }
370364}
371365
372- PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlots (const char * memberName, int memberNameLen, PythonQtSlotInfo* tail, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset)
366+ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlots (const char * memberName, PythonQtSlotInfo* tail, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset)
373367{
374368 QListIterator<PythonQtSlotInfo*> it (_decoratorSlots);
375369 while (it.hasNext ()) {
376370
377371 PythonQtSlotInfo* infoOrig = it.next ();
378-
379- const char * sigStart = infoOrig->metaMethod ()->signature ();
380- if (qstrncmp (" static_" , sigStart, 7 )==0 ) {
381- sigStart += 7 ;
382- sigStart += findCharOffset (sigStart, ' _' )+1 ;
372+ QByteArray signature = PythonQtUtils::methodName (*infoOrig->metaMethod ());
373+ if (signature.startsWith (" static_" )) {
374+ int offset = signature.indexOf (' _' , 7 );
375+ signature = signature.mid (offset+1 );
383376 }
384- int offset = findCharOffset (sigStart, ' (' );
385- if (memberNameLen == offset && qstrncmp (memberName, sigStart, offset)==0 ) {
377+ if (signature == memberName) {
386378 // make a copy, otherwise we will have trouble on overloads!
387379 PythonQtSlotInfo* info = new PythonQtSlotInfo (*infoOrig);
388380 info->setUpcastingOffset (upcastingOffset);
@@ -391,7 +383,7 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlots(const char* memberName,
391383 tail->setNextInfo (info);
392384 } else {
393385 PythonQtMemberInfo newInfo (info);
394- memberCache.insert (memberName , newInfo);
386+ memberCache.insert (signature , newInfo);
395387 }
396388 tail = info;
397389 }
@@ -410,26 +402,23 @@ void PythonQtClassInfo::listDecoratorSlotsFromDecoratorProvider(QStringList& lis
410402 if ((m.methodType () == QMetaMethod::Method ||
411403 m.methodType () == QMetaMethod::Slot) && m.access () == QMetaMethod::Public) {
412404
413- const char * sigStart = m. signature ( );
405+ QByteArray signature = PythonQtUtils::methodName (m );
414406 bool isClassDeco = false ;
415- if (qstrncmp (sigStart, " static_" , 7 )== 0 ) {
407+ if (signature. startsWith ( " static_" ) ) {
416408 // skip the static_classname_ part of the string
417- sigStart += 7 + 1 + strlen (className ());
409+ signature = signature. mid ( 7 + 1 + strlen (className () ));
418410 isClassDeco = true ;
419- } else if (qstrncmp (sigStart, " new_" , 4 )== 0 ) {
411+ } else if (signature. startsWith ( " new_" ) ) {
420412 continue ;
421- } else if (qstrncmp (sigStart, " delete_" , 7 )== 0 ) {
413+ } else if (signature. startsWith ( " delete_" ) ) {
422414 continue ;
423- } else if (qstrncmp (sigStart, " py_" , 3 )== 0 ) {
415+ } else if (signature. startsWith ( " py_" ) ) {
424416 // hide everything that starts with py_
425417 continue ;
426418 }
427- // find the first '('
428- int offset = findCharOffset (sigStart, ' (' );
429-
430419 // XXX no checking is currently done if the slots have correct first argument or not...
431420 if (!metaOnly || isClassDeco) {
432- list << QString::fromLatin1 (sigStart, offset );
421+ list << QString::fromLatin1 (signature. constData () );
433422 }
434423 }
435424 }
@@ -484,9 +473,7 @@ QStringList PythonQtClassInfo::memberList()
484473 if (((m.methodType () == QMetaMethod::Method ||
485474 m.methodType () == QMetaMethod::Slot) && m.access () == QMetaMethod::Public)
486475 || m.methodType ()==QMetaMethod::Signal) {
487- QByteArray signa (m.signature ());
488- signa = signa.left (signa.indexOf (' (' ));
489- l << signa;
476+ l << PythonQtUtils::methodName (m);
490477 }
491478 }
492479 }
@@ -641,7 +628,7 @@ QString PythonQtClassInfo::help()
641628 for (int i = 0 ; i < numMethods; i++) {
642629 QMetaMethod m = _meta->method (i);
643630 if (m.methodType () == QMetaMethod::Signal) {
644- h += QString (m. signature ()) + " \n " ;
631+ h += QString (PythonQtUtils:: signature (m )) + " \n " ;
645632 }
646633 }
647634 }
0 commit comments