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 <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-28 19:31:34 +03:00
parent e42586803b
commit 75d4dc82b5
5 changed files with 15 additions and 23 deletions

View file

@ -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<QAbstractSocket::SocketState>();
qRegisterMetaType<QAbstractSocket::SocketError>();
}
/*! \internal

View file

@ -24,14 +24,14 @@
#include <QtCore/qiodevice.h>
#include <QtCore/qobject.h>
#include <QtCore/qmetatype.h>
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
#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

View file

@ -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}
*/

View file

@ -23,14 +23,13 @@
#define QLOCALSOCKET_H
#include <QtCore/qiodevice.h>
#include <QtCore/qmetatype.h>
#include <QtNetwork/qabstractsocket.h>
#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

View file

@ -49,6 +49,9 @@ QLocalSocketPrivate::QLocalSocketPrivate()
void QLocalSocketPrivate::init()
{
qRegisterMetaType<QLocalSocket::LocalSocketState>();
qRegisterMetaType<QLocalSocket::LocalSocketError>();
Q_Q(QLocalSocket);
// QIODevice signals
q->connect(&unixSocket, SIGNAL(aboutToClose()), q, SIGNAL(aboutToClose()));