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>
This commit is contained in:
parent
1af068332b
commit
0e60e4bf19
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user