mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Fix memory leak and invite filtering
This commit is contained in:
parent
1295e84020
commit
2abd2870e0
2 changed files with 12 additions and 10 deletions
|
@ -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_,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue