From 17d6e00597fdc1c8f25808735cbc728c4a6b3506 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 26 Nov 2020 22:32:55 +0100 Subject: Enable QT_NO_URL_CAST_FROM_STRING and QT_STRICT_ITERATORS. * QT_NO_URL_CAST_FROM_STRING makes it clearer where QUrls are created from QStrings (which incurs a parsing cost). * QT_STRICT_ITERATORS helps detecting where begin()/end() is used instead of cbegin()/cend(). KDE developers have verified that the generated assembly code is identical. --- lib/connection.cpp | 4 ++-- lib/events/eventcontent.cpp | 2 +- lib/events/eventcontent.h | 2 +- lib/events/roommemberevent.cpp | 2 +- lib/jobs/basejob.cpp | 2 +- lib/room.cpp | 2 +- lib/ssosession.cpp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/connection.cpp b/lib/connection.cpp index e84b8080..2a86d2eb 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -931,8 +931,8 @@ void Connection::doInDirectChat(User* u, // There can be more than one DC; find the first valid (existing and // not left), and delete inexistent (forgotten?) ones along the way. DirectChatsMap removals; - for (auto it = std::as_const(d->directChats).find(u); - it != d->directChats.end() && it.key() == u; ++it) { + for (auto it = d->directChats.constFind(u); + it != d->directChats.constEnd() && it.key() == u; ++it) { const auto& roomId = *it; if (auto r = room(roomId, JoinState::Join)) { Q_ASSERT(r->id() == roomId); diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp index 802d8176..0cb9e292 100644 --- a/lib/events/eventcontent.cpp +++ b/lib/events/eventcontent.cpp @@ -89,7 +89,7 @@ void ImageInfo::fillInfoJson(QJsonObject* infoJson) const } Thumbnail::Thumbnail(const QJsonObject& infoJson) - : ImageInfo(infoJson["thumbnail_url"_ls].toString(), + : ImageInfo(QUrl(infoJson["thumbnail_url"_ls].toString()), infoJson["thumbnail_info"_ls].toObject()) {} diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 0d4c047e..9c167d4b 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -189,7 +189,7 @@ namespace EventContent { using InfoT::InfoT; explicit UrlBasedContent(const QJsonObject& json) : TypedBase(json) - , InfoT(json["url"].toString(), json["info"].toObject(), + , InfoT(QUrl(json["url"].toString()), json["info"].toObject(), json["filename"].toString()) { // A small hack to facilitate links creation in QML. diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp index be47e412..913bde74 100644 --- a/lib/events/roommemberevent.cpp +++ b/lib/events/roommemberevent.cpp @@ -52,7 +52,7 @@ MemberEventContent::MemberEventContent(const QJsonObject& json) : membership(fromJson(json["membership"_ls])) , isDirect(json["is_direct"_ls].toBool()) , displayName(fromJson>(json["displayname"_ls])) - , avatarUrl(fromJson>(json["avatar_url"_ls])) + , avatarUrl(fromJson>(json["avatar_url"_ls])) , reason(json["reason"_ls].toString()) { if (displayName) diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index 1f0e84ba..422931ee 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -534,7 +534,7 @@ BaseJob::Status BaseJob::prepareError() } if (errCode == "M_CONSENT_NOT_GIVEN") { - d->errorUrl = errorJson.value("consent_uri"_ls).toString(); + d->errorUrl = QUrl(errorJson.value("consent_uri"_ls).toString()); return { UserConsentRequiredError }; } if (errCode == "M_UNSUPPORTED_ROOM_VERSION" diff --git a/lib/room.cpp b/lib/room.cpp index 1af294a7..a309cd24 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1947,7 +1947,7 @@ void Room::uploadFile(const QString& id, const QUrl& localFilename, }); connect(job, &BaseJob::success, this, [this, id, localFilename, job] { d->fileTransfers[id].status = FileTransferInfo::Completed; - emit fileTransferCompleted(id, localFilename, job->contentUri()); + emit fileTransferCompleted(id, localFilename, QUrl(job->contentUri())); }); connect(job, &BaseJob::failure, this, std::bind(&Private::failedTransfer, d, id, job->errorString())); diff --git a/lib/ssosession.cpp b/lib/ssosession.cpp index be701204..3c6ec48b 100644 --- a/lib/ssosession.cpp +++ b/lib/ssosession.cpp @@ -70,7 +70,7 @@ SsoSession::~SsoSession() QUrl SsoSession::ssoUrl() const { return d->ssoUrl; } -QUrl SsoSession::callbackUrl() const { return d->callbackUrl; } +QUrl SsoSession::callbackUrl() const { return QUrl(d->callbackUrl); } void SsoSession::Private::processCallback() { -- cgit v1.2.3