mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Fix use after free from Qml widget
This commit is contained in:
parent
2174f6507f
commit
18ff58edb3
3 changed files with 13 additions and 3 deletions
|
@ -171,6 +171,14 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
activateWindow();
|
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(
|
connect(
|
||||||
this,
|
this,
|
||||||
&ChatPage::initializeViews,
|
&ChatPage::initializeViews,
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
|
|
||||||
RoomlistModel::RoomlistModel(TimelineViewManager *parent)
|
RoomlistModel::RoomlistModel(TimelineViewManager *parent)
|
||||||
: manager(parent)
|
: QAbstractListModel(parent)
|
||||||
|
, manager(parent)
|
||||||
{
|
{
|
||||||
connect(ChatPage::instance(), &ChatPage::decryptSidebarChanged, this, [this]() {
|
connect(ChatPage::instance(), &ChatPage::decryptSidebarChanged, this, [this]() {
|
||||||
auto decrypt = ChatPage::instance()->userSettings()->decryptSidebar();
|
auto decrypt = ChatPage::instance()->userSettings()->decryptSidebar();
|
||||||
|
|
|
@ -129,7 +129,8 @@ TimelineViewManager::userStatus(QString id) const
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *parent)
|
TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *parent)
|
||||||
: imgProvider(new MxcImageProvider())
|
: QObject(parent)
|
||||||
|
, imgProvider(new MxcImageProvider())
|
||||||
, colorImgProvider(new ColorImageProvider())
|
, colorImgProvider(new ColorImageProvider())
|
||||||
, blurhashProvider(new BlurhashProvider())
|
, blurhashProvider(new BlurhashProvider())
|
||||||
, callManager_(callManager)
|
, callManager_(callManager)
|
||||||
|
@ -230,7 +231,7 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
|
||||||
"Error: Only enums");
|
"Error: Only enums");
|
||||||
|
|
||||||
#ifdef USE_QUICK_VIEW
|
#ifdef USE_QUICK_VIEW
|
||||||
view = new QQuickView();
|
view = new QQuickView(parent);
|
||||||
container = QWidget::createWindowContainer(view, parent);
|
container = QWidget::createWindowContainer(view, parent);
|
||||||
#else
|
#else
|
||||||
view = new QQuickWidget(parent);
|
view = new QQuickWidget(parent);
|
||||||
|
|
Loading…
Reference in a new issue