From 986b561c344e7f500418e37ecd03b36c8011bcf6 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 30 Apr 2021 15:33:17 +0200 Subject: [PATCH] Fix crash when you have no rooms and open the profile as well as not rendering rooms without groups --- src/ChatPage.cpp | 5 ++++- src/timeline/TimelineModel.cpp | 6 +++--- src/timeline/TimelineModel.h | 3 +-- src/timeline/TimelineViewManager.h | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 2d7c75d1..c5199ff1 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -31,6 +31,7 @@ #include "Utils.h" #include "ui/OverlayModal.h" #include "ui/Theme.h" +#include "ui/UserProfile.h" #include "notifications/Manager.h" @@ -100,7 +101,8 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) user_info_widget_ = new UserInfoWidget(sideBar_); connect(user_info_widget_, &UserInfoWidget::openGlobalUserProfile, this, [this]() { - view_manager_->activeTimeline()->openUserProfile(utils::localUser(), true); + UserProfile *userProfile = new UserProfile("", utils::localUser(), view_manager_); + emit view_manager_->openProfile(userProfile); }); user_mentions_popup_ = new popups::UserMentions(); @@ -1187,6 +1189,7 @@ ChatPage::getProfileInfo() nhlog::net()->critical("failed to retrieve joined groups: {} {}", static_cast(err->status_code), err->matrix_error.error); + emit updateGroupsInfo({}); return; } diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 2f7bfdd2..c472ab33 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -854,12 +854,12 @@ TimelineModel::viewDecryptedRawMessage(QString id) const } void -TimelineModel::openUserProfile(QString userid, bool global) +TimelineModel::openUserProfile(QString userid) { - UserProfile *userProfile = new UserProfile(global ? "" : room_id_, userid, manager_, this); + UserProfile *userProfile = new UserProfile(room_id_, userid, manager_, this); connect( this, &TimelineModel::roomAvatarUrlChanged, userProfile, &UserProfile::updateAvatarUrl); - emit openProfile(userProfile); + emit manager_->openProfile(userProfile); } void diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 4dbb1c08..33e77f53 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -223,7 +223,7 @@ public: Q_INVOKABLE void viewRawMessage(QString id) const; Q_INVOKABLE void forwardMessage(QString eventId, QString roomId); Q_INVOKABLE void viewDecryptedRawMessage(QString id) const; - Q_INVOKABLE void openUserProfile(QString userid, bool global = false); + Q_INVOKABLE void openUserProfile(QString userid); Q_INVOKABLE void openRoomSettings(); Q_INVOKABLE void editAction(QString id); Q_INVOKABLE void replyAction(QString id); @@ -322,7 +322,6 @@ signals: void newCallEvent(const mtx::events::collections::TimelineEvents &event); void scrollToIndex(int index); - void openProfile(UserProfile *profile); void openRoomSettingsDialog(RoomSettings *settings); void newMessageToSend(mtx::events::collections::TimelineEvents event); diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index aa24b220..b23a61db 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -93,6 +93,7 @@ signals: void focusChanged(); void focusInput(); void openImageOverlayInternalCb(QString eventId, QImage img); + void openProfile(UserProfile *profile); public slots: void updateReadReceipts(const QString &room_id, const std::vector &event_ids);