Skip to content

Commit cc20cb4

Browse files
committed
Fix build warning with Qt >= 5.14.0
Qt 5.14 (late 2019) introduced new version 3 of QML type registration structs. New version came with new struct fields, which cased compiler to complain about missing field initializer for generalizedQobjectApi. warning: src/qtdeclarative.rs: In function 'void __cpp_closure_9949451391349003668(const char* const&, const int&, const int&, const char* const&, const QMetaObject* const&, QObject* (* const&)(QQmlEngine*, QJSEngine*))': warning: src/qtdeclarative.rs:548:9: warning: missing initializer for member 'QQmlPrivate::RegisterSingletonType::generalizedQobjectApi' [-Wmissing-field-initializers] warning: 548 | }; warning: | ^ By the way, they will be reset to 0 and rewritten completely in Qt 6. See QTBUG-82241.
1 parent a281c25 commit cc20cb4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

qmetaobject/src/qtdeclarative.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,11 @@ pub fn qml_register_singleton_type<T: QObject + QSingletonInit + Sized + Default
535535
/*instanceMetaObject*/ meta_object,
536536
// new in version 2
537537
/*typeId*/ ptrType,
538-
/*revision*/ 0
538+
/*revision*/ 0,
539+
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
540+
// new in version 3
541+
/*generalizedQobjectApi*/ {}
542+
#endif
539543
};
540544

541545
QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api);

0 commit comments

Comments
 (0)