Fix use after free from Qml widget

pull/605/head
Nicolas Werner 4 years ago
parent 2174f6507f
commit 18ff58edb3
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 8
      src/ChatPage.cpp
  2. 3
      src/timeline/RoomlistModel.cpp
  3. 5
      src/timeline/TimelineViewManager.cpp

@ -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,

@ -13,7 +13,8 @@
#include "UserSettingsPage.h"
RoomlistModel::RoomlistModel(TimelineViewManager *parent)
: manager(parent)
: QAbstractListModel(parent)
, manager(parent)
{
connect(ChatPage::instance(), &ChatPage::decryptSidebarChanged, this, [this]() {
auto decrypt = ChatPage::instance()->userSettings()->decryptSidebar();

@ -129,7 +129,8 @@ TimelineViewManager::userStatus(QString id) const
}
TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *parent)
: imgProvider(new MxcImageProvider())
: QObject(parent)
, imgProvider(new MxcImageProvider())
, colorImgProvider(new ColorImageProvider())
, blurhashProvider(new BlurhashProvider())
, callManager_(callManager)
@ -230,7 +231,7 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
"Error: Only enums");
#ifdef USE_QUICK_VIEW
view = new QQuickView();
view = new QQuickView(parent);
container = QWidget::createWindowContainer(view, parent);
#else
view = new QQuickWidget(parent);

Loading…
Cancel
Save