Qt6: prevent QML object from being garbage collected

It appears that the QML object that is created when assigning the source
to the StatsView in the ui can be garbage collected and therefore
destroyed and re-instantiated without our knowledge. So instead of
trying to keep a pointer around, we end up looking up the object address
when needed.
We still ask the JS code to not garbage collect the object - but that
clearly isn't enough to prevent it from being destroyed when the parent
widget changes.

Without this fix opening the statistics will crash with Qt6.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2022-02-16 15:42:21 -08:00
parent 2ede1a4563
commit 2368a183e1
2 changed files with 26 additions and 9 deletions

View file

@ -31,7 +31,7 @@ slots:
private:
Ui::StatsWidget ui;
StatsState state;
StatsView *view;
StatsView *getView();
void updateUi();
void updateRestrictionLabel();
std::vector<std::unique_ptr<QCheckBox>> features;