aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2020-11-26 22:32:55 +0100
committerDavid Faure <faure@kde.org>2020-11-26 22:32:55 +0100
commit17d6e00597fdc1c8f25808735cbc728c4a6b3506 (patch)
treef27be06719da60306413cfb62d6eb578d69bdf98
parent21554bccc39ab2f63869c244ed880686805887cb (diff)
downloadlibquotient-17d6e00597fdc1c8f25808735cbc728c4a6b3506.tar.gz
libquotient-17d6e00597fdc1c8f25808735cbc728c4a6b3506.zip
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.
-rw-r--r--CMakeLists.txt2
-rw-r--r--lib/connection.cpp4
-rw-r--r--lib/events/eventcontent.cpp2
-rw-r--r--lib/events/eventcontent.h2
-rw-r--r--lib/events/roommemberevent.cpp2
-rw-r--r--lib/jobs/basejob.cpp2
-rw-r--r--lib/room.cpp2
-rw-r--r--lib/ssosession.cpp2
8 files changed, 9 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d5d286d..4bb2bd31 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -257,7 +257,7 @@ file(GLOB_RECURSE api_SRCS ${add_CONFIGURE_DEPENDS} ${FULL_CSAPI_DIR}/*.cpp)
set(tests_SRCS tests/quotest.cpp)
add_library(${PROJECT_NAME} ${lib_SRCS} ${api_SRCS})
-target_compile_definitions(${PROJECT_NAME} PRIVATE QT_NO_JAVA_STYLE_ITERATORS)
+target_compile_definitions(${PROJECT_NAME} PRIVATE QT_NO_JAVA_STYLE_ITERATORS QT_NO_URL_CAST_FROM_STRING QT_NO_CAST_TO_ASCII)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.16.0"
AND NOT CMAKE_CXX_COMPILER_ID STREQUAL GNU) # https://bugzilla.redhat.com/show_bug.cgi?id=1721553
target_precompile_headers(${PROJECT_NAME} PRIVATE lib/converters.h)
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<MembershipType>(json["membership"_ls]))
, isDirect(json["is_direct"_ls].toBool())
, displayName(fromJson<Omittable<QString>>(json["displayname"_ls]))
- , avatarUrl(fromJson<Omittable<QUrl>>(json["avatar_url"_ls]))
+ , avatarUrl(fromJson<Omittable<QString>>(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()
{