diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-02-11 11:12:57 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-02-18 20:39:06 +0000 |
commit | 2f334e5619d7ae437c802c60c579d54e954aadd0 (patch) | |
tree | f2608e96d8f96369c8630f63915d786aff514864 | |
parent | e78c413d0f5df58c4b996baae947f96fe8752d55 (diff) |
QDesktopServices: make QOpenUrlHandlerRegistry a non-QObject
It seems to have been a QObject solely for its single slot.
But since Qt 5, slots need no longer be defined on QObjects, so we can
remove the inheritance from QObject now. We still need a QObject as
the context object in connect(), but that can be just be an aggregated
naked QObject.
Saves 26 relocations, ~1.5KiB in TEXT and ~0.3KiB in DATA on optimized
GCC 11.2 Linux AMD64 C++20 builds.
Change-Id: Ic45a8e892ec2bd5de5de8fbd32ec7a167c501803
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 0e60e4bf199b38594defcc80de276e460273b7fe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/gui/util/qdesktopservices.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 8f237960d6..a4c4fa4c2c 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -58,9 +58,8 @@ QT_BEGIN_NAMESPACE -class QOpenUrlHandlerRegistry : public QObject +class QOpenUrlHandlerRegistry { - Q_OBJECT public: QOpenUrlHandlerRegistry() = default; @@ -75,7 +74,8 @@ public: HandlerHash handlers; #if QT_VERSION < QT_VERSION_CHECK(6, 6, 0) -public Q_SLOTS: + QObject context; + void handlerDestroyed(QObject *handler); #endif @@ -336,8 +336,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c h.name = method; registry->handlers.insert(scheme.toLower(), h); #if QT_VERSION < QT_VERSION_CHECK(6, 6, 0) - QObject::connect(receiver, SIGNAL(destroyed(QObject*)), - registry, SLOT(handlerDestroyed(QObject*)), + QObject::connect(receiver, &QObject::destroyed, ®istry->context, + [registry](QObject *obj) { registry->handlerDestroyed(obj); }, Qt::DirectConnection); #endif } @@ -358,6 +358,4 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme) QT_END_NAMESPACE -#include "qdesktopservices.moc" - #endif // QT_NO_DESKTOPSERVICES |