From a4f34202b47f91f7fdfbe2006b2eae10b9b8eeac Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Thu, 11 Nov 2021 14:35:54 +0100 Subject: Fix a few quirks in converters.h --- lib/converters.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/converters.h b/lib/converters.h index cc6378e4..2df18b03 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -242,12 +242,11 @@ struct JsonObjectConverter> { for (const auto& e : s) json.insert(toJson(e), QJsonObject {}); } - static auto fillFrom(const QJsonObject& json, QSet& s) + static void fillFrom(const QJsonObject& json, QSet& s) { s.reserve(s.size() + json.size()); for (auto it = json.begin(); it != json.end(); ++it) s.insert(it.key()); - return s; } }; @@ -260,7 +259,7 @@ struct HashMapFromJson { } static void fillFrom(const QJsonObject& jo, HashMapT& h) { - h.reserve(jo.size()); + h.reserve(h.size() + jo.size()); for (auto it = jo.begin(); it != jo.end(); ++it) h[it.key()] = fromJson(it.value()); } -- cgit v1.2.3 From fb30d455e2dbeed8c242cfbeb153f834b0358f11 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 12 Nov 2021 11:10:30 +0100 Subject: Fix building with GCC It didn't like using QT_IGNORE_DEPRECATIONS inside a statement. --- lib/room.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/room.cpp b/lib/room.cpp index 6bccc405..c11f7990 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -633,9 +633,12 @@ Room::Changes Room::Private::setLastReadEvent(User* u, QString eventId) connection->callApi(BackgroundRequest, id, storedId); emit q->readMarkerMoved(eventId, storedId); - // TODO: Drop ReadMarkerChange in 0.8 - return QT_IGNORE_DEPRECATIONS(Change::ReadMarkerChange) - | Change::OtherChange; + + // NB: GCC (at least 10) only accepts QT_IGNORE_DEPRECATIONS around + // a statement, not within a statement + QT_IGNORE_DEPRECATIONS( // TODO: Drop ReadMarkerChange in 0.8 + return Change::ReadMarkerChange | Change::OtherChange; + ) } return Change::NoChange; } @@ -2816,7 +2819,9 @@ Room::Changes Room::processAccountDataEvent(EventPtr&& event) << currentData->matrixType(); emit accountDataChanged(currentData->matrixType()); // TODO: Drop AccountDataChange in 0.8 - QT_IGNORE_DEPRECATIONS(changes |= AccountDataChange|OtherChange); + // NB: GCC (at least 10) only accepts QT_IGNORE_DEPRECATIONS around + // a statement, not within a statement + QT_IGNORE_DEPRECATIONS(changes |= AccountDataChange | OtherChange;) } return changes; } -- cgit v1.2.3 From d8c9f0d5802f8b1c3ef362964dac5c8d60a61871 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Mon, 15 Nov 2021 23:03:09 +0100 Subject: Port away from deprecated upfront percent encoding --- lib/room.cpp | 3 +-- lib/user.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/room.cpp b/lib/room.cpp index c11f7990..c2c4ba78 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -750,8 +750,7 @@ Room::Changes Room::Private::markMessagesAsRead(rev_iter_t upToMarker) if ((*upToMarker)->senderId() != q->localUser()->id()) { connection->callApi(BackgroundRequest, id, QStringLiteral("m.read"), - QUrl::toPercentEncoding( - (*upToMarker)->id())); + (*upToMarker)->id()); break; } } diff --git a/lib/user.cpp b/lib/user.cpp index 88549e5d..7da71dba 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -66,7 +66,7 @@ User::~User() = default; void User::load() { auto* profileJob = - connection()->callApi(QUrl::toPercentEncoding(id())); + connection()->callApi(id()); connect(profileJob, &BaseJob::result, this, [this, profileJob] { d->defaultName = profileJob->displayname(); d->defaultAvatar = Avatar(QUrl(profileJob->avatarUrl())); -- cgit v1.2.3 From cb7b9e8d04f060893a5ffb8cfa22c627c7dbe507 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Tue, 16 Nov 2021 00:53:39 +0100 Subject: Port away from implicit 'this' captures in lambdas Deprecated with C++20 --- lib/room.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/room.cpp b/lib/room.cpp index c11f7990..bef06dfe 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -572,13 +572,13 @@ QImage Room::avatar(int width, int height) { if (!d->avatar.url().isEmpty()) return d->avatar.get(connection(), width, height, - [=] { emit avatarChanged(); }); + [this] { emit avatarChanged(); }); // Use the first (excluding self) user's avatar for direct chats const auto dcUsers = directChatUsers(); for (auto* u : dcUsers) if (u != localUser()) - return u->avatar(width, height, this, [=] { emit avatarChanged(); }); + return u->avatar(width, height, this, [this] { emit avatarChanged(); }); return {}; } @@ -861,7 +861,7 @@ void Room::Private::getAllMembers() allMembersJob = connection->callApi( id, connection->nextBatchToken(), "join"); auto nextIndex = timeline.empty() ? 0 : timeline.back().index() + 1; - connect(allMembersJob, &BaseJob::success, q, [=] { + connect(allMembersJob, &BaseJob::success, q, [this, nextIndex] { Q_ASSERT(timeline.empty() || nextIndex <= q->maxTimelineIndex() + 1); auto roomChanges = updateStateFrom(allMembersJob->chunk()); // Replay member events that arrived after the point for which @@ -1973,7 +1973,7 @@ void Room::Private::getPreviousContent(int limit, const QString &filter) eventsHistoryJob = connection->callApi(id, prevBatch, "b", "", limit, filter); emit q->eventsHistoryJobChanged(); - connect(eventsHistoryJob, &BaseJob::success, q, [=] { + connect(eventsHistoryJob, &BaseJob::success, q, [this] { prevBatch = eventsHistoryJob->end(); addHistoricalMessageEvents(eventsHistoryJob->chunk()); }); -- cgit v1.2.3