Fix use after free from Qml widget

This commit is contained in:
Nicolas Werner 2021-05-30 00:23:57 +02:00
parent 2174f6507f
commit 18ff58edb3
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 13 additions and 3 deletions

View file

@ -171,6 +171,14 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
activateWindow();
});
connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, [this]() {
// ensure the qml context is shutdown before we destroy all other singletons
// Otherwise Qml will try to access the room list or settings, after they have been
// destroyed
topLayout_->removeWidget(view_manager_->getWidget());
delete view_manager_->getWidget();
});
connect(
this,
&ChatPage::initializeViews,