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

  • 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());

    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
        const int id = qRegisterMetaType<T>(); // make sure it's registered

    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

  • Lifetime Qt Champion

    Its not something with const ?

    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.

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

  • Lifetime Qt Champion

    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 ?

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.