[Development] Applications using -fno-rtti
annulen at yandex.ru
Sat Jun 20 20:42:30 CEST 2020
20.06.2020, 21:34, "Alberto Mardegan" <mardy at users.sourceforge.net>:
> Hi all!
> A couple of days ago a bug was filed against a project of mine, which
> has been built with -fno-rtti since Qt4 times:
> The bug, it appears, is a crash in QProcess due to the use of typeid(),
> which was introduced in Qt 5.15:
> I think I missed an announcement about Qt applications having to use
> RTTI; on the opposite, I thought that the whole point of QMetaObject was
> not to require RTTI support; has this changed?
> Anyway, were I to submit a patch replacing typeid() with something which
> does not require RTTI ("q->metaObject() == QProcess::staticMetaObject()"
> would work, I guess? Or maybe even comparing q->className()?), would
> that be accepted?
I think it should use qobject_cast.
Comparing metaObject() with staticMetaObject() is wrong because it would fail
even for QProcess. OTOH, using qobject_cast would handle classes derived
from QProcess correctly, unlike code with typeid().
More information about the Development