From 539d7a90722607c7538e16590688fd5381e3da49 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Wed, 27 Oct 2021 23:11:53 +0200 Subject: [PATCH] Revert "Remove unneeded const_casts" This reverts commit 9135ad06ea7669193d8f4b7f226c421462486e71. --- declarativeplugin/responsewaiter.cpp | 8 ++++---- declarativeplugin/responsewaiter.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/declarativeplugin/responsewaiter.cpp b/declarativeplugin/responsewaiter.cpp index 683a05350..c62330c9f 100644 --- a/declarativeplugin/responsewaiter.cpp +++ b/declarativeplugin/responsewaiter.cpp @@ -45,7 +45,7 @@ DBusResponseWaiter::DBusResponseWaiter() QVariant DBusResponseWaiter::waitForReply(QVariant variant) const { - if (QDBusPendingCall* call = extractPendingCall(variant)) + if (QDBusPendingCall* call = const_cast(extractPendingCall(variant))) { call->waitForFinished(); @@ -77,7 +77,7 @@ DBusAsyncResponse::DBusAsyncResponse(QObject* parent) void DBusAsyncResponse::setPendingCall(QVariant variant) { - if (QDBusPendingCall* call = DBusResponseWaiter::instance()->extractPendingCall(variant)) + if (QDBusPendingCall* call = const_cast(DBusResponseWaiter::instance()->extractPendingCall(variant))) { QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call); watcher->setProperty("pengingCallVariant", variant); @@ -124,13 +124,13 @@ void DBusAsyncResponse::onTimeout() Q_EMIT error(QStringLiteral("timeout when waiting dbus response!")); } -QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const +const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const { for (int type : qAsConst(m_registered)) { if (variant.canConvert(QVariant::Type(type))) { - return static_cast(variant.value()); + return reinterpret_cast(variant.constData()); } } diff --git a/declarativeplugin/responsewaiter.h b/declarativeplugin/responsewaiter.h index b25a74685..e5b19f806 100644 --- a/declarativeplugin/responsewaiter.h +++ b/declarativeplugin/responsewaiter.h @@ -25,7 +25,7 @@ public: ///extract QDbusPendingCall from \p variant and blocks until completed Q_INVOKABLE QVariant waitForReply(QVariant variant) const; - QDBusPendingCall* extractPendingCall(QVariant& variant) const; + const QDBusPendingCall* extractPendingCall(QVariant& variant) const; private: DBusResponseWaiter();