On Sun, May 2, 2021 at 8:50 PM Nicholas Yue <yue.nicho...@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.
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to