From 75d4dc82b565d2645d853de33e63a8caccfe83de Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 28 Jun 2023 19:31:34 +0300 Subject: [PATCH] register socket error and state enums as metatypes makes no sense to have to register types externally that the socket classes use (connect) internally Signed-off-by: Ivailo Monev --- src/network/socket/qabstractsocket.cpp | 10 ++-------- src/network/socket/qabstractsocket.h | 6 ++++-- src/network/socket/qlocalsocket.cpp | 8 -------- src/network/socket/qlocalsocket.h | 11 ++++++----- src/network/socket/qlocalsocket_unix.cpp | 3 +++ 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 3879301fa..e3e42f87b 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -189,10 +189,6 @@ This signal is emitted after an error occurred. The \a socketError parameter describes the type of error that occurred. - QAbstractSocket::SocketError is not a registered metatype, so for queued - connections, you will have to register it with Q_DECLARE_METATYPE() and - qRegisterMetaType(). - \sa error(), errorString(), {Creating Custom Qt Types} */ @@ -202,10 +198,6 @@ This signal is emitted whenever QAbstractSocket's state changes. The \a socketState parameter is the new state. - QAbstractSocket::SocketState is not a registered metatype, so for queued - connections, you will have to register it with Q_REGISTER_METATYPE() and - qRegisterMetaType(). - \sa state(), {Creating Custom Qt Types} */ @@ -365,6 +357,8 @@ QAbstractSocketPrivate::QAbstractSocketPrivate() state(QAbstractSocket::UnconnectedState), socketError(QAbstractSocket::UnknownSocketError) { + qRegisterMetaType(); + qRegisterMetaType(); } /*! \internal diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index 5d5d48c07..ead26fe37 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -24,14 +24,14 @@ #include #include +#include + #ifndef QT_NO_DEBUG_STREAM #include #endif - QT_BEGIN_NAMESPACE - class QHostAddress; class QAbstractSocketPrivate; @@ -172,5 +172,7 @@ Q_NETWORK_EXPORT QDebug operator<<(QDebug, QAbstractSocket::SocketState); QT_END_NAMESPACE +Q_DECLARE_METATYPE(QAbstractSocket::SocketError); +Q_DECLARE_METATYPE(QAbstractSocket::SocketState); #endif // QABSTRACTSOCKET_H diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index 47613b247..35f99cb58 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -286,10 +286,6 @@ QT_BEGIN_NAMESPACE This signal is emitted after an error occurred. The \a socketError parameter describes the type of error that occurred. - QLocalSocket::LocalSocketError is not a registered metatype, so for queued - connections, you will have to register it with Q_DECLARE_METATYPE() and - qRegisterMetaType(). - \sa error(), errorString(), {Creating Custom Qt Types} */ @@ -299,10 +295,6 @@ QT_BEGIN_NAMESPACE This signal is emitted whenever QLocalSocket's state changes. The \a socketState parameter is the new state. - QLocalSocket::SocketState is not a registered metatype, so for queued - connections, you will have to register it with Q_DECLARE_METATYPE() and - qRegisterMetaType(). - \sa state(), {Creating Custom Qt Types} */ diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h index e51dc5531..395437dc9 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -23,14 +23,13 @@ #define QLOCALSOCKET_H #include +#include #include +#ifndef QT_NO_LOCALSOCKET QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LOCALSOCKET - class QLocalSocketPrivate; class Q_NETWORK_EXPORT QLocalSocket : public QIODevice @@ -118,9 +117,11 @@ Q_NETWORK_EXPORT QDebug operator<<(QDebug, QLocalSocket::LocalSocketError); Q_NETWORK_EXPORT QDebug operator<<(QDebug, QLocalSocket::LocalSocketState); #endif -#endif // QT_NO_LOCALSOCKET - QT_END_NAMESPACE +Q_DECLARE_METATYPE(QLocalSocket::LocalSocketState); +Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError); + +#endif // QT_NO_LOCALSOCKET #endif // QLOCALSOCKET_H diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index f722e1d2d..76d4c3301 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -49,6 +49,9 @@ QLocalSocketPrivate::QLocalSocketPrivate() void QLocalSocketPrivate::init() { + qRegisterMetaType(); + qRegisterMetaType(); + Q_Q(QLocalSocket); // QIODevice signals q->connect(&unixSocket, SIGNAL(aboutToClose()), q, SIGNAL(aboutToClose())); -- 2.11.0