summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-02-11 11:12:57 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-02-18 20:29:37 +0100
commit0e60e4bf199b38594defcc80de276e460273b7fe (patch)
tree0936cabba9d7f777b5794de1678c17a75b2fe94c /src/gui/util
parent1af068332bd8a834ae684cfa8c586f71f7e7bd28 (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. Pick-to: 6.3 6.2 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>
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qdesktopservices.cpp12
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, &registry->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