diff options
author | NepNep21 <nepnep91@protonmail.com> | 2023-12-19 23:53:55 -0300 |
---|---|---|
committer | NepNep21 <nepnep91@protonmail.com> | 2023-12-19 23:53:55 -0300 |
commit | 2abd2870e0b6b37fecdfbcfdb3a16024a086e1b4 (patch) | |
tree | fb2c7d26eaae2ed3555d9912a0b430295f25c876 /src | |
parent | Other occurences (diff) | |
download | nheko-2abd2870e0b6b37fecdfbcfdb3a16024a086e1b4.tar.xz |
Fix memory leak and invite filtering
Diffstat (limited to 'src')
-rw-r--r-- | src/timeline/InputBar.cpp | 17 | ||||
-rw-r--r-- | src/ui/UserProfile.cpp | 5 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index 191aebdc..ba1d7880 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -954,18 +954,17 @@ InputBar::command(const QString &command, QString args) void InputBar::toggleIgnore(const QString &user, const bool ignored) { - QSharedPointer<UserProfile> profile( - new UserProfile(QString(), user, TimelineViewManager::instance())); - connect(profile.get(), &UserProfile::failedToFetchProfile, [user] { + UserProfile *profile = new UserProfile(QString(), user, TimelineViewManager::instance()); + connect(profile, &UserProfile::failedToFetchProfile, [user] { MainWindow::instance()->showNotification(tr("Failed to fetch user %1").arg(user)); }); - connect(profile.get(), - &UserProfile::globalUsernameRetrieved, - [profile, ignored](const QString &user_id) { - Q_UNUSED(user_id) - profile->setIgnored(ignored); - }); + connect( + profile, &UserProfile::globalUsernameRetrieved, [profile, ignored](const QString &user_id) { + Q_UNUSED(user_id) + profile->setIgnored(ignored); + profile->deleteLater(); + }); } MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_, diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp index ffb69aa4..c7254e23 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp @@ -281,9 +281,12 @@ UserProfile::setIgnored(bool ignore) if (ignore) { const QHash<QString, RoomInfo> invites = cache::invites(); + FilteredRoomlistModel *room_model = FilteredRoomlistModel::instance(); for (auto room = invites.keyBegin(), end = invites.keyEnd(); room != end; room++) { - FilteredRoomlistModel::instance()->declineInvite(*room); + if (room_model->getRoomPreviewById(*room).inviterUserId() == userid) { + room_model->declineInvite(*room); + } } } } |