Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Multiple qRegisterMetaType<T>() result in Binary compatibility break.

    General and Desktop
    2
    6
    1070
    Loading More Posts
    • 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.
    • J
      JulienMaille last edited by JulienMaille

      Hi everyone,
      I'm getting headaches trying to expose a class to both ActiveX and QtScript.
      In order to expose it to activeX, I use Qt macro QAXCLASS(MyClass) which will call :

      #define QAXCLASS(Class)
      factory = new QAxClass<Class>(typeLibID().toString(), appID().toString());
      qRegisterMetaType<Class*>(#Class"*");
      [snip]

      Later in my dll handling the script, I will register the class qScriptRegisterMetaType<MyClass*>(eng, qObjectToScriptValue, qObjectFromScriptValue) which will call

      template<typename T>
      int qScriptRegisterMetaType(
          QScriptEngine *eng,
          QScriptValue (*toScriptValue)(QScriptEngine *, const T &t),
          void (*fromScriptValue)(const QScriptValue &, T &t),
          const QScriptValue &prototype = QScriptValue()
      #ifndef qdoc
          , T * /* dummy */ = 0
      #endif
      )
      {
          const int id = qRegisterMetaType<T>(); // make sure it's registered
      [snip]
      

      this will compile and link, but on execution I get a qFatal stating that:

      QMetaType::registerType: Binary comaptibility break. Type flags for type 'MyClass*' [2258] don't match. Previously registered TypeFlags(0x104), now registering TypeFlags(0x10c)

      Since all these codes are hidden in Qt macro, is there anything I can do?
      Thanks in advance for your help

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi
        Its not something with const ?
        https://bugreports.qt.io/browse/QTBUG-47631

        Seems to be the same TypeFlags values in the bug report but
        im not aware if other qRegisterMetaType scenarios result in same
        ID/values for TypeFlags.

        1 Reply Last reply Reply Quote 0
        • J
          JulienMaille last edited by

          No I'm not trying to register const.
          However the first registration happen in the main app (QAXCLASS macro) while the latter is called from a plugin.

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @JulienMaille last edited by

            @JulienMaille
            Hmm, searching Google that error also seen when plugin loaded another version
            of Qt Dlls. ( than main app)
            I assume this cant be the case ?

            1 Reply Last reply Reply Quote 0
            • J
              JulienMaille last edited by

              Yes this can't be the case. (the funny part is it compiles fine with Qt4)

              1 Reply Last reply Reply Quote 0
              • J
                JulienMaille last edited by

                I finally found the trick. Write my own macro that doesn't blindly call qRegisterMetaType

                #define MYAXTYPE(Class) \
                    factory = new MyAxType<Class>(typeLibID().toString(), appID().toString()); \
                    if( !QMetaType::isRegistered(QMetaType::type(#Class"*")) ) \
                        qRegisterMetaType<Class*>(#Class"*"); \
                    keys = factory->featureList(); \
                    for (it = keys.begin(); it != keys.end(); ++it) { \
                        factoryKeys += *it; \
                        factories.insert(*it, factory); \
                        creatable.insert(*it, false); \
                    }\
                
                1 Reply Last reply Reply Quote 1
                • First post
                  Last post