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. [Bug] Dumpcpp generates wrong qt_metacall id

[Bug] Dumpcpp generates wrong qt_metacall id

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 331 Views
  • 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.
  • G Offline
    G Offline
    Gundz
    wrote on last edited by Gundz
    #1

    Hello,

    I was trying to call C# code by using ActiveQt and a COM dll.
    After some trying i started noticing some weird problems:
    Sometimes the methods where not called and returning a default value.

    I did some testing and noticed the following, this my cs file:

    using System.Runtime.InteropServices;
    
    namespace SuperTest
    {
        [ComVisible( true )]
        [Guid( "DB1797F5-7198-4411-8563-D05F4E904956" )]
        [InterfaceType( ComInterfaceType.InterfaceIsDual )]
        public interface ISuperTest
        {
    
            string AA();
    
            string BB();
    
            string SS();
    
            string AS();
    
        }
    
        [ComVisible( true )]
        [Guid( "BA9AC84B-C7FC-41CF-8B2F-1764EB773D4B" )]
        [ClassInterface( ClassInterfaceType.None )]
        public class SuperTest : ISuperTest
        {
            string ISuperTest.AA()
            {
                return "AA";
            }
    
            string ISuperTest.BB()
            {
                return "BB";
            }
    
            string ISuperTest.SS()
            {
                return "SS";
            }
    
            string ISuperTest.AS()
            {
                return "AS";
            }
        }
    }
    

    (.net framework 4.8 compiled in 64 bit)

    Then i generate the .cpp/.h files by using dumpcpp.exe MyTLBFile.tlb, and use this Qt main

    #include <QAxObject>
    #include <QApplication>
    #include "supertestcom.h"
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        qInfo() << "Hello World !";
    
        SuperTestCOM::SuperTest test;
    
        qInfo() << test.AA();
        qInfo() << test.BB();
        qInfo() << test.SS();
        qInfo() << test.AS();
    
        return 0;
    }
    
    

    and i get the following output

    Hello World !
    "AA"
    "BB"
    ""
    "AS"
    

    After inspecting the .h file generated by dumpcpp.exe i noticed that the id of the qt_metacall is wrong

    inline QString SuperTest::AA()
    {
        QString qax_result;
        void *_a[] = {(void*)&qax_result};
        qt_metacall(QMetaObject::InvokeMetaMethod, 8, _a);
        return qax_result;
    }
    
    inline QString SuperTest::AS()
    {
        QString qax_result;
        void *_a[] = {(void*)&qax_result};
        qt_metacall(QMetaObject::InvokeMetaMethod, 9, _a);
        return qax_result;
    }
    
    inline QString SuperTest::BB()
    {
        QString qax_result;
        void *_a[] = {(void*)&qax_result};
        qt_metacall(QMetaObject::InvokeMetaMethod, 10, _a);
        return qax_result;
    }
    
    inline bool SuperTest::Equals(const QVariant& obj)
    {
        bool qax_result;
        void *_a[] = {(void*)&qax_result, (void*)&obj};
        qt_metacall(QMetaObject::InvokeMetaMethod, 11, _a);
        return qax_result;
    }
    
    inline int SuperTest::GetHashCode()
    {
        int qax_result;
        void *_a[] = {(void*)&qax_result};
        qt_metacall(QMetaObject::InvokeMetaMethod, 12, _a);
        return qax_result;
    }
    
    inline mscorlib::_Type* SuperTest::GetType()
    {
        mscorlib::_Type* qax_result = 0;
    #ifdef QAX_DUMPCPP_MSCORLIB_H
        qRegisterMetaType<mscorlib::_Type*>("mscorlib::_Type*");
        qRegisterMetaType<mscorlib::_Type>("mscorlib::_Type");
    #endif
        void *_a[] = {(void*)&qax_result};
        qt_metacall(QMetaObject::InvokeMetaMethod, 13, _a);
        return qax_result;
    }
    
    inline QString SuperTest::SS()
    {
        QString qax_result;
        void *_a[] = {(void*)&qax_result};
        qt_metacall(QMetaObject::InvokeMetaMethod, 14, _a);
        return qax_result;
    }
    

    qt_metacall(QMetaObject::InvokeMetaMethod, 14, _a); should be qt_metacall(QMetaObject::InvokeMetaMethod, 11, _a);
    If i change it to 11 and recompile it works.

    Hello World !
    "AA"
    "BB"
    "SS"
    "AS"
    

    So i guess that there is some kind of issue where the method names are sorted, but their id's are not changed accordingly.

    Tested in Qt 6.2.0, 6.3.0 and 5.9.9.

    Best regards.
    Gundz.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      You should report a repeatable bug over at https://bugreports.qt.io/secure after looking for existing reports of the same behaviour.

      QTBUG-27792 looks similar (ancient and no resolution)

      G 1 Reply Last reply
      0
      • C ChrisW67

        You should report a repeatable bug over at https://bugreports.qt.io/secure after looking for existing reports of the same behaviour.

        QTBUG-27792 looks similar (ancient and no resolution)

        G Offline
        G Offline
        Gundz
        wrote on last edited by
        #3

        @ChrisW67 oh sorry, will do. thanks

        1 Reply Last reply
        0

        • Login

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