Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. invokeMethod is messing up signatures

invokeMethod is messing up signatures

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 649 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by ocgltd
    #1

    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)

    Christian EhrlicherC 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #6

      Start with a clean build dir and make sure you don't have generated files in your source dir.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • ocgltdO 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)

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @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.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • ocgltdO Offline
          ocgltdO Offline
          ocgltd
          wrote on last edited by ocgltd
          #3

          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...

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            Since you did not even show the correct output for the failure case how should we help?

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • ocgltdO Offline
              ocgltdO Offline
              ocgltd
              wrote on last edited by ocgltd
              #5

              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?

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                Start with a clean build dir and make sure you don't have generated files in your source dir.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                1
                • ocgltdO Offline
                  ocgltdO Offline
                  ocgltd
                  wrote on last edited by
                  #7

                  That solved it. I'm not sure what happened, but something got messed up my build dir.

                  1 Reply Last reply
                  1
                  • ocgltdO ocgltd has marked this topic as solved on

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved