Bug 343779

Summary: metafunction.h needs to be updated for Qt 5
Product: [Frameworks and Libraries] frameworks-kross Reporter: Dmitry Shachnev <mitya57>
Component: generalAssignee: David Faure <faure>
Status: RESOLVED FIXED    
Severity: normal CC: faure, perezmeyer
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In: 5.7
Sentry Crash Report:

Description Dmitry Shachnev 2015-02-04 17:16:21 UTC
Kross' metafunction.h has the following code:

    // static metaobject
    staticMetaObject.d.superdata = &QObject::staticMetaObject;
    staticMetaObject.d.stringdata = m_stringData.data();
    staticMetaObject.d.data = m_data;
    staticMetaObject.d.extradata = 0;

Here, d is a struct that is different between Qt 4 and Qt 5. In Qt 4, it was declared as:

    struct { // private data
        const QMetaObject *superdata;
        const char *stringdata;
        const uint *data;
        const void *extradata;
    } d;

And in Qt 5 it is declared as:

    struct { // private data
        const QMetaObject *superdata;
        const QByteArrayData *stringdata;
        const uint *data;
        typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **);
        StaticMetacallFunction static_metacall;
        const QMetaObject * const *relatedMetaObjects;
        void *extradata; //reserved for future use
    } d;

As one can see, there are more fields there and they are of a different size. For example, assigning a char * to QByteArrayData * is not possible (one probably needs to use QByteArray's data_ptr() member function instead of just data()).

Reproducible: Always

Steps to Reproduce:
1. Build anything that uses metafunction.h.

Actual Results:  
The build fails.

Expected Results:  
The build should succeed.
Comment 1 David Faure 2015-02-08 12:30:39 UTC
Git commit f079cc63c0fb217dffe57ec300c94facc4ed1886 by David Faure.
Committed on 08/02/2015 at 12:28.
Pushed by dfaure into branch 'master'.

MetaFunction: rewrite the dynamic metaobject writing to make it work with Qt5.

With unittest.
FIXED-IN: 5.7
CHANGELOG: fix Kross::MetaFunction so it works with Qt5's metaobject system

M  +13   -0    CMakeLists.txt
M  +8    -0    autotests/CMakeLists.txt
A  +103  -0    autotests/metafunctiontest.cpp     [License: UNKNOWN]  *
M  +101  -31   src/core/metafunction.h

The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


http://commits.kde.org/kross/f079cc63c0fb217dffe57ec300c94facc4ed1886