qdbuscpp2xml: Register QtDBus metatypes
Explicitly register QtDBus-specific metatypes before attempting to generate output. This fixes a bug when types like QDBusObjectPath are sometimes ignored by this tool. Export QDBusMetaTypeId::init() for that reason. Add a regression test to tst_qdbuscpp2xml. Fixes: QTBUG-34550 Change-Id: I16faa79a794d09a26bad45e18730379681a20b50 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
b2d24044c2
commit
86cfafcb5a
@ -37,7 +37,7 @@ QMetaType signature(); // QDBusSignature
|
||||
QMetaType error(); // QDBusError
|
||||
QMetaType unixfd(); // QDBusUnixFileDescriptor
|
||||
|
||||
void init();
|
||||
Q_DBUS_EXPORT void init();
|
||||
}; // namespace QDBusMetaTypeId
|
||||
|
||||
inline QMetaType QDBusMetaTypeId::message()
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <qdbusconnection.h> // for the Export* flags
|
||||
#include <private/qdbusconnection_p.h> // for the qDBusCheckAsyncTag
|
||||
#include <private/qdbusmetatype_p.h> // for QDBusMetaTypeId::init()
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
@ -431,6 +432,8 @@ int main(int argc, char **argv)
|
||||
args.append(QString::fromLocal8Bit(argv[n]));
|
||||
parseCmdLine(args);
|
||||
|
||||
QDBusMetaTypeId::init();
|
||||
|
||||
QList<ClassDef> classes;
|
||||
|
||||
if (args.isEmpty())
|
||||
|
@ -14,6 +14,7 @@ endif()
|
||||
qt_internal_add_test(tst_qdbuscpp2xml
|
||||
SOURCES
|
||||
test1.h
|
||||
test2.h
|
||||
tst_qdbuscpp2xml.cpp
|
||||
LIBRARIES
|
||||
Qt::DBusPrivate
|
||||
@ -22,6 +23,7 @@ qt_internal_add_test(tst_qdbuscpp2xml
|
||||
# Resources:
|
||||
set(qdbuscpp2xml_resource_files
|
||||
"test1.h"
|
||||
"test2.h"
|
||||
)
|
||||
|
||||
qt_internal_add_resource(tst_qdbuscpp2xml "qdbuscpp2xml"
|
||||
|
24
tests/auto/tools/qdbuscpp2xml/test2.h
Normal file
24
tests/auto/tools/qdbuscpp2xml/test2.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#ifndef TEST2_H
|
||||
#define TEST2_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
// Regression test for QTBUG-34550
|
||||
class Test2 : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "net.company.object")
|
||||
Q_PROPERTY(QDBusObjectPath objectProperty READ objectProperty)
|
||||
Q_PROPERTY(QList<QDBusObjectPath> objectPropertyList READ objectPropertyList)
|
||||
public:
|
||||
Test2(QObject *parent = nullptr) : QObject(parent) { }
|
||||
|
||||
QDBusObjectPath objectProperty() { return {}; }
|
||||
|
||||
QList<QDBusObjectPath> objectPropertyList() { return {}; }
|
||||
};
|
||||
|
||||
#endif // TEST2_H
|
@ -9,7 +9,7 @@
|
||||
#include <QtDBus/private/dbus_minimal_p.h>
|
||||
|
||||
#include "test1.h"
|
||||
|
||||
#include "test2.h"
|
||||
|
||||
// in qdbusxmlgenerator.cpp
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -47,6 +47,7 @@ private:
|
||||
void tst_qdbuscpp2xml::initTestCase()
|
||||
{
|
||||
m_tests.insert("test1", new Test1);
|
||||
m_tests.insert("test2", new Test2);
|
||||
}
|
||||
|
||||
void tst_qdbuscpp2xml::cleanupTestCase()
|
||||
@ -61,14 +62,16 @@ void tst_qdbuscpp2xml::qdbuscpp2xml_data()
|
||||
|
||||
QBitArray doneFlags(int(QDBusConnection::ExportAllContents) + 1);
|
||||
for (int flag = 0x10; flag < QDBusConnection::ExportScriptableContents; flag += 0x10) {
|
||||
QTest::newRow("xmlgenerator-" + QByteArray::number(flag)) << "test1" << flag;
|
||||
doneFlags.setBit(flag);
|
||||
for (int mask = QDBusConnection::ExportAllSlots; mask <= QDBusConnection::ExportAllContents; mask += 0x110) {
|
||||
int flags = flag | mask;
|
||||
if (doneFlags.testBit(flags))
|
||||
continue;
|
||||
QTest::newRow("xmlgenerator-" + QByteArray::number(flags)) << "test1" << flags;
|
||||
doneFlags.setBit(flags);
|
||||
for (const auto &testFile : m_tests.keys()) {
|
||||
QTest::newRow("xmlgenerator-" + QByteArray::number(flag) + "-" + qUtf8Printable(testFile)) << testFile << flag;
|
||||
doneFlags.setBit(flag);
|
||||
for (int mask = QDBusConnection::ExportAllSlots; mask <= QDBusConnection::ExportAllContents; mask += 0x110) {
|
||||
int flags = flag | mask;
|
||||
if (doneFlags.testBit(flags))
|
||||
continue;
|
||||
QTest::newRow("xmlgenerator-" + QByteArray::number(flags) + "-" + qUtf8Printable(testFile)) << testFile << flags;
|
||||
doneFlags.setBit(flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user