From bc2797612c6de6e3781275baf9e03cda0d073f6a Mon Sep 17 00:00:00 2001 From: Alex Robenko Date: Tue, 12 Dec 2023 08:45:50 +1000 Subject: [PATCH] Fixes to Qt6 support. --- README.md | 2 +- lib/src/MsgMgrImpl.cpp | 2 +- plugin/serial_socket/SerialSocket.cpp | 11 ++++++-- plugin/ssl_socket/client/SslSocket.cpp | 15 ++++++---- plugin/tcp_socket/client/Socket.cpp | 16 ++++++++--- plugin/tcp_socket/proxy/Socket.cpp | 39 ++++++++++++++++++-------- plugin/tcp_socket/server/Socket.cpp | 28 +++++++++++------- plugin/udp_socket/Socket.cpp | 28 ++++++++++++------ script/full_debug_build.sh | 27 ++++++++++++++++++ script/full_debug_build_clang.sh | 8 ++++++ script/full_debug_build_gcc.sh | 8 ++++++ 11 files changed, 140 insertions(+), 44 deletions(-) create mode 100755 script/full_debug_build.sh create mode 100755 script/full_debug_build_clang.sh create mode 100755 script/full_debug_build_gcc.sh diff --git a/README.md b/README.md index 703d0af..986e74f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Overview -This project also contains a set of tool applications , which can be used to +This project contains a set of tool applications , which can be used to develop, monitor and debug custom binary communication protocols, that were developed using the [COMMS Library](https://github.com/commschamp/comms). All the applications are plug-in based, i.e. plug-ins are used to define diff --git a/lib/src/MsgMgrImpl.cpp b/lib/src/MsgMgrImpl.cpp index c9cf76f..4646811 100644 --- a/lib/src/MsgMgrImpl.cpp +++ b/lib/src/MsgMgrImpl.cpp @@ -351,7 +351,7 @@ void MsgMgrImpl::socketDataReceived(DataInfoPtr dataInfoPtr) } QList data; - data.append(std::move(dataInfoPtr)); + data.append(dataInfoPtr); for (auto filt : m_filters) { assert(filt); diff --git a/plugin/serial_socket/SerialSocket.cpp b/plugin/serial_socket/SerialSocket.cpp index 8a3122d..a6bd370 100644 --- a/plugin/serial_socket/SerialSocket.cpp +++ b/plugin/serial_socket/SerialSocket.cpp @@ -21,6 +21,7 @@ #include "comms/CompileControl.h" CC_DISABLE_WARNINGS() +#include #include CC_ENABLE_WARNINGS() @@ -49,13 +50,19 @@ SerialSocket::SerialSocket() m_name = firstDev->systemLocation(); } +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) + connect( + &m_serial, &QSerialPort::errorOccurred, + this, &SerialSocket::errorOccurred); +#else // #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) connect( &m_serial, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(errorOccurred(QSerialPort::SerialPortError))); +#endif // #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) connect( - &m_serial, SIGNAL(readyRead()), - this, SLOT(performRead())); + &m_serial, &QSerialPort::readyRead, + this, &SerialSocket::performRead); } SerialSocket::~SerialSocket() noexcept = default; diff --git a/plugin/ssl_socket/client/SslSocket.cpp b/plugin/ssl_socket/client/SslSocket.cpp index e0c18f8..290c736 100644 --- a/plugin/ssl_socket/client/SslSocket.cpp +++ b/plugin/ssl_socket/client/SslSocket.cpp @@ -50,14 +50,17 @@ const QString ToPropName("ssl.to"); SslSocket::SslSocket() { connect( - &m_socket, SIGNAL(disconnected()), - this, SLOT(socketDisconnected())); + &m_socket, &QSslSocket::disconnected, + this, &SslSocket::socketDisconnected); + connect( - &m_socket, SIGNAL(readyRead()), - this, SLOT(readFromSocket())); + &m_socket, &QSslSocket::readyRead, + this, &SslSocket::readFromSocket); + connect( - &m_socket, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); + &m_socket, &QSslSocket::errorOccurred, + this, &SslSocket::socketErrorOccurred); + connect( &m_socket, SIGNAL(sslErrors(const QList&)), this, SLOT(sslErrorsOccurred(const QList&))); diff --git a/plugin/tcp_socket/client/Socket.cpp b/plugin/tcp_socket/client/Socket.cpp index 46f51a6..1dcb9dc 100644 --- a/plugin/tcp_socket/client/Socket.cpp +++ b/plugin/tcp_socket/client/Socket.cpp @@ -20,6 +20,7 @@ #include "comms/CompileControl.h" CC_DISABLE_WARNINGS() +#include #include CC_ENABLE_WARNINGS() @@ -49,14 +50,21 @@ const QString ToPropName("tcp.to"); Socket::Socket() { connect( - &m_socket, SIGNAL(disconnected()), - this, SLOT(socketDisconnected())); + &m_socket, &QTcpSocket::disconnected, + this, &Socket::socketDisconnected); connect( - &m_socket, SIGNAL(readyRead()), - this, SLOT(readFromSocket())); + &m_socket, &QTcpSocket::readyRead, + this, &Socket::readFromSocket); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + connect( + &m_socket, &QTcpSocket::errorOccurred, + this, &Socket::socketErrorOccurred); +#else // #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect( &m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); +#endif } Socket::~Socket() noexcept diff --git a/plugin/tcp_socket/proxy/Socket.cpp b/plugin/tcp_socket/proxy/Socket.cpp index 1a6a100..28dec7c 100644 --- a/plugin/tcp_socket/proxy/Socket.cpp +++ b/plugin/tcp_socket/proxy/Socket.cpp @@ -20,6 +20,7 @@ #include "comms/CompileControl.h" CC_DISABLE_WARNINGS() +#include #include CC_ENABLE_WARNINGS() @@ -48,12 +49,12 @@ const QString ToPropName("tcp.to"); Socket::Socket() { QObject::connect( - &m_server, SIGNAL(newConnection()), - this, SLOT(newConnection())); + &m_server, &QTcpServer::newConnection, + this, &Socket::newConnection); QObject::connect( - &m_server, SIGNAL(acceptError(QAbstractSocket::SocketError)), - this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); + &m_server, &QTcpServer::acceptError, + this, &Socket::socketErrorOccurred); } Socket::~Socket() noexcept @@ -146,25 +147,39 @@ void Socket::newConnection() { auto *newConnSocket = m_server.nextPendingConnection(); connect( - newConnSocket, SIGNAL(disconnected()), - this, SLOT(clientConnectionTerminated())); + newConnSocket, &QTcpSocket::disconnected, + this, &Socket::clientConnectionTerminated); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + connect( + newConnSocket, &QTcpSocket::errorOccurred, + this, &Socket::socketErrorOccurred); +#else // #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect( newConnSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); +#endif // #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) ConnectionSocketPtr connectionSocket(new QTcpSocket); connect( - connectionSocket.get(), SIGNAL(connected()), - this, SLOT(connectionSocketConnected())); + connectionSocket.get(), &QTcpSocket::connected, + this, &Socket::connectionSocketConnected); connect( - connectionSocket.get(), SIGNAL(disconnected()), - this, SLOT(connectionSocketDisconnected())); + connectionSocket.get(), &QTcpSocket::disconnected, + this, &Socket::connectionSocketDisconnected); + connect( + connectionSocket.get(), &QTcpSocket::readyRead, + this, &Socket::readFromConnectionSocket); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect( - connectionSocket.get(), SIGNAL(readyRead()), - this, SLOT(readFromConnectionSocket())); + connectionSocket.get(), &QTcpSocket::errorOccurred, + this, &Socket::socketErrorOccurred); +#else // #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect( connectionSocket.get(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); +#endif if (m_remoteHost.isEmpty()) { m_remoteHost = QHostAddress(QHostAddress::LocalHost).toString(); diff --git a/plugin/tcp_socket/server/Socket.cpp b/plugin/tcp_socket/server/Socket.cpp index 435ccbc..b71bd5c 100644 --- a/plugin/tcp_socket/server/Socket.cpp +++ b/plugin/tcp_socket/server/Socket.cpp @@ -20,6 +20,7 @@ #include "comms/CompileControl.h" CC_DISABLE_WARNINGS() +#include #include CC_ENABLE_WARNINGS() @@ -48,12 +49,12 @@ const QString ToPropName("tcp.to"); Socket::Socket() { QObject::connect( - &m_server, SIGNAL(acceptError(QAbstractSocket::SocketError)), - this, SLOT(acceptErrorOccurred(QAbstractSocket::SocketError))); + &m_server, &QTcpServer::acceptError, + this, &Socket::acceptErrorOccurred); QObject::connect( - &m_server, SIGNAL(newConnection()), - this, SLOT(newConnection())); + &m_server, &QTcpServer::newConnection, + this, &Socket::newConnection); } Socket::~Socket() noexcept @@ -128,17 +129,24 @@ void Socket::newConnection() auto *newConnSocket = m_server.nextPendingConnection(); m_sockets.push_back(newConnSocket); connect( - newConnSocket, SIGNAL(disconnected()), - newConnSocket, SLOT(deleteLater())); + newConnSocket, &QTcpSocket::disconnected, + newConnSocket, &Socket::deleteLater); connect( - newConnSocket, SIGNAL(disconnected()), - this, SLOT(connectionTerminated())); + newConnSocket, &QTcpSocket::disconnected, + this, &Socket::connectionTerminated); connect( - newConnSocket, SIGNAL(readyRead()), - this, SLOT(readFromSocket())); + newConnSocket, &QTcpSocket::readyRead, + this, &Socket::readFromSocket); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + connect( + newConnSocket, &QTcpSocket::errorOccurred, + this, &Socket::socketErrorOccurred); +#else // #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect( newConnSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); +#endif // #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) } void Socket::connectionTerminated() diff --git a/plugin/udp_socket/Socket.cpp b/plugin/udp_socket/Socket.cpp index be6bde5..3532d6b 100644 --- a/plugin/udp_socket/Socket.cpp +++ b/plugin/udp_socket/Socket.cpp @@ -21,6 +21,7 @@ #include "comms/CompileControl.h" CC_DISABLE_WARNINGS() +#include #include CC_ENABLE_WARNINGS() @@ -54,20 +55,31 @@ Socket::Socket() m_broadcastPropName(DefaultBroadcastPropName) { connect( - &m_socket, SIGNAL(disconnected()), - this, SLOT(socketDisconnected())); + &m_socket, &QUdpSocket::disconnected, + this, &Socket::socketDisconnected); connect( - &m_socket, SIGNAL(readyRead()), - this, SLOT(readFromSocket())); + &m_socket, &QUdpSocket::readyRead, + this, &Socket::readFromSocket); connect( - &m_socket, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); + &m_broadcastSocket, &QUdpSocket::readyRead, + this, &Socket::readFromBroadcastSocket); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect( - &m_broadcastSocket, SIGNAL(readyRead()), - this, SLOT(readFromBroadcastSocket())); + &m_socket, &QUdpSocket::errorOccurred, + this, &Socket::socketErrorOccurred); + + connect( + &m_broadcastSocket, &QUdpSocket::errorOccurred, + this, &Socket::socketErrorOccurred); +#else // #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + connect( + &m_socket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); connect( &m_broadcastSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); +#endif // #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) } Socket::~Socket() noexcept diff --git a/script/full_debug_build.sh b/script/full_debug_build.sh new file mode 100755 index 0000000..7b34c24 --- /dev/null +++ b/script/full_debug_build.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ -z "${CC}" -o -z "$CXX" ]; then + echo "ERROR: Compilers are not provided" + exit 1 +fi + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOT_DIR=$( dirname ${SCRIPT_DIR} ) +export BUILD_DIR="${ROOT_DIR}/build.full.${CC}" +export COMMON_INSTALL_DIR=${BUILD_DIR}/install +export COMMON_BUILD_TYPE=Debug +export EXTERNALS_DIR=${ROOT_DIR}/externals +mkdir -p ${BUILD_DIR} + +${SCRIPT_DIR}/prepare_externals.sh + +cd ${BUILD_DIR} +cmake .. -DCMAKE_INSTALL_PREFIX=${COMMON_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} \ + -DCC_TOOLS_QT_BUILD_DEMO_PROTOCOL=ON "$@" + +procs=$(nproc) +if [ -n "${procs}" ]; then + procs_param="--parallel ${procs}" +fi + +cmake --build ${BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param} diff --git a/script/full_debug_build_clang.sh b/script/full_debug_build_clang.sh new file mode 100755 index 0000000..e198c79 --- /dev/null +++ b/script/full_debug_build_clang.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +export CC=clang +export CXX=clang++ + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +${SCRIPT_DIR}/full_debug_build.sh + diff --git a/script/full_debug_build_gcc.sh b/script/full_debug_build_gcc.sh new file mode 100755 index 0000000..70c765a --- /dev/null +++ b/script/full_debug_build_gcc.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +export CC=gcc +export CXX=g++ + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +${SCRIPT_DIR}/full_debug_build.sh +