invokeMethod is messing up signatures
-
wrote 25 days ago last edited by ocgltd
I am running into a strange runtime error when trying to invoke a method. I invoke the method as follows:
QMetaObject::invokeMethod( classPtr, methodName, Qt::QueuedConnection, Q_ARG(ClassA_Types::enumD, ClassA_Types::enumD1), Q_ARG(ClassA_Types::enumE, ClassA_Types::enumE1), Q_ARG(ClassB, sMessagePtr->getter()), Q_ARG(ClassB, rMessagePtr->getter()), Q_ARG(ClassA_Types::MyStruct, sinfo), Q_ARG(ClassA_Types::MyStruct, sinfo) );
but at run time the signature does not match candidate! When I compile and run under Qt 5.15.12 I get this error:
When I compile and run under Qt 6.5.0 I get this error:
QMetaObject::invokeMethod: No such method MyNameSpace::ClassC::inv_rx_response(ClassA_Types::enumD,ClassB,ClassB) Candidates are: inv_rx_response(ClassA_Types::enumD,ClassA_Types::enumE,MyNameSpace::ClassB,ClassB,ClassA_Types::MyStruct,ClassA_Types::MyStruct)
(I added spacing into the error message to make it obvious where the namespace appears)
-
Start with a clean build dir and make sure you don't have generated files in your source dir.
-
I am running into a strange runtime error when trying to invoke a method. I invoke the method as follows:
QMetaObject::invokeMethod( classPtr, methodName, Qt::QueuedConnection, Q_ARG(ClassA_Types::enumD, ClassA_Types::enumD1), Q_ARG(ClassA_Types::enumE, ClassA_Types::enumE1), Q_ARG(ClassB, sMessagePtr->getter()), Q_ARG(ClassB, rMessagePtr->getter()), Q_ARG(ClassA_Types::MyStruct, sinfo), Q_ARG(ClassA_Types::MyStruct, sinfo) );
but at run time the signature does not match candidate! When I compile and run under Qt 5.15.12 I get this error:
When I compile and run under Qt 6.5.0 I get this error:
QMetaObject::invokeMethod: No such method MyNameSpace::ClassC::inv_rx_response(ClassA_Types::enumD,ClassB,ClassB) Candidates are: inv_rx_response(ClassA_Types::enumD,ClassA_Types::enumE,MyNameSpace::ClassB,ClassB,ClassA_Types::MyStruct,ClassA_Types::MyStruct)
(I added spacing into the error message to make it obvious where the namespace appears)
@ocgltd said in invokeMethod is messing up signatures:
inv_rx_response(ClassA_Types::enumD,ClassB,ClassB)
This does not match your code.
Please provide a minimal, compilable example of your problem.
-
wrote 25 days ago last edited by ocgltd
I've used invokeMethod many times, and I'm sure a minimum example will work fine. I was hoping for some advice on what I might be doing wrong to cause this. I'm pretty sure I've done something silly but just can see it.
And the project way to large to post...
-
Since you did not even show the correct output for the failure case how should we help?
-
wrote 25 days ago last edited by ocgltd
After some experimenting I'm narrow the problem down. Here's where it gets really strange. I placed ALL of my invokation parameters (Q_ARGS) into a single struct, and pass that struct to invokeMethod.
The error still appears, and the candidate function shows the single struct. But, the calling method still shows the old 3 parameters! It's as if the code wasn't compiling properly.
I reset all file permissions in my source tree, cleaned, and qmaked, and recompiled. Still same problem. I assume this is something in the moc file by I have no idea how to fix. Why is invokeMethod still trying to use the old 3 parameters?
Can someone make a suggestion on diagnosing/fixing?
-
Start with a clean build dir and make sure you don't have generated files in your source dir.
-
wrote 24 days ago last edited by
That solved it. I'm not sure what happened, but something got messed up my build dir.
-
1/7