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. Multiple qRegisterMetaType<T>() result in Binary compatibility break.

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.5k 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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by JulienMaille
    #1

    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
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        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.

        mrjjM 1 Reply Last reply
        0
        • J JulienMaille

          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.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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
          0
          • J Offline
            J Offline
            JulienMaille
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JulienMaille
              wrote on last edited by
              #6

              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
              1

              • Login

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