[Interest] Language and translator : Learning and questions

Konstantin Shegunov kshegunov at gmail.com
Mon May 3 14:49:33 CEST 2021

On Sun, May 2, 2021 at 8:50 PM Nicholas Yue <yue.nicholas at gmail.com> wrote:

>   (2) I see some examples where a translator is removed before installing
> a new one, I comment that away and it still works, is there some issue
> lurking in the background that will cause a crash later ?

QCoreApplicaiton supports multiple translators and the translator is
deregistered automatically on destruction. The only problem here is
ideological: you not clearly declaring the QObject's lifetime. Keeping a
QObject in an external reference counted pointer wrapper can create
unintuitive and hard to diagnose dangling pointer crashes (i.e. losing the
reference while processing a slot on said reference), not to mention
wasteful. The QObject already supports weak pointer semantics internally
(a.k.a. the QPointer support). Much better is to revert to an owning
semantics - std::unique_ptr, QScopedPointer or the 'evil' raw pointer, or
simply to rely on the parent-child relationship.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210503/87e62b03/attachment.html>

More information about the Interest mailing list