[clazy] [Bug 389994] New: new-check: Avoid explicit qRegisterMetaType / Q_DECLARE_METATYPE
bugzilla_noreply at kde.org
bugzilla_noreply at kde.org
Wed Feb 7 08:20:53 GMT 2018
https://bugs.kde.org/show_bug.cgi?id=389994
Bug ID: 389994
Summary: new-check: Avoid explicit qRegisterMetaType /
Q_DECLARE_METATYPE
Product: clazy
Version: unspecified
Platform: Other
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: NOR
Component: general
Assignee: unassigned-bugs at kde.org
Reporter: aklitzing at gmail.com
CC: smartins at kde.org
Target Milestone: ---
It would be helpful if clazy could check if a class is able to register itself
in Qt's meta-object-system.
Sometimes it is a forgotten include (forward declared) or something like this
that the moc cannot see the whole class and won't generate the
"qRegisterMetaType" itself. Most times the developer will add qRegisterMetaType
somewhere because Qt said it at runtime. But clazy could help here to warn if a
class is used in signal/slot and moc is not able to generate the registration
as it is the better way to let moc do the registration.
moc can generate q qt_static_metacall with stuff like this:
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
switch (_id) {
default: *reinterpret_cast<int*>(_a[0]) = -1; break;
case 0:
switch (*reinterpret_cast<int*>(_a[1])) {
default: *reinterpret_cast<int*>(_a[0]) = -1; break;
case 1:
*reinterpret_cast<int*>(_a[0]) = qRegisterMetaType<
QSharedPointer<CUSTOM_CLASS> >(); break;
}
break;
moc has some more possibilities to detect own types like Q_PROPERTY usage.
See:
https://code.qt.io/cgit/qt/qtbase.git/tree/src/tools/moc/generator.cpp
https://woboq.com/blog/qmetatype-knows-your-types.html
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Unassigned-bugs
mailing list