[Development] Applications using -fno-rtti

Konstantin Tokarev 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:
>
>   https://bugzilla.opensuse.org/show_bug.cgi?id=1172904
>
> The bug, it appears, is a crash in QProcess due to the use of typeid(),
> which was introduced in Qt 5.15:
>
> https://code.qt.io/cgit/qt/qtbase.git/commit/?h=5.15&id=97645478de3ceffce11f58eab140c4c775e48be5
>
> 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().


-- 
Regards,
Konstantin



More information about the Development mailing list