From 2374b221dab8185f38e92f254ee24b102c820f78 Mon Sep 17 00:00:00 2001 From: re2zero Date: Thu, 22 Oct 2026 10:51:54 +0800 Subject: [PATCH] fix(compat): support Qt 5.11 and GCC 8 toolchain Guard the two new errorOccurred connects so Qt < 5.15 keeps using error(QAbstractSocket::SocketError), matching the existing pattern in singleapplication.cpp. Link stdc++fs when compiling with GCC < 9, where std::filesystem symbols live in a separate archive (UOS 20 toolchain); GCC >= 9 folds them into libstdc++. Log: support Qt 5.11 and GCC 8 toolchain Influence: no behavior change on Qt >= 5.15 and GCC >= 9; makes the tunnel branch build on Qt 5.11.3 (UOS 20). --- CMakeLists.txt | 6 ++++++ src/lib/common/manager/tunnelmanager.cpp | 5 +++++ src/lib/cooperation/core/net/helper/sharehelper.cpp | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b49e19fdf..d0c41acab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,12 @@ project(dde-cooperation VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +# GCC 8 (UOS 20) keeps std::filesystem in a separate archive, GCC >= 9 folds it +# into libstdc++ and the separate archive may no longer exist. +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lstdc++fs") +endif() + set(CMAKE_POSITION_INDEPENDENT_CODE ON) if (NOT WIN32) diff --git a/src/lib/common/manager/tunnelmanager.cpp b/src/lib/common/manager/tunnelmanager.cpp index 8963d7ac0..de5f31752 100644 --- a/src/lib/common/manager/tunnelmanager.cpp +++ b/src/lib/common/manager/tunnelmanager.cpp @@ -267,7 +267,12 @@ void TunnelManager::setupSocket(Stream *stream) connect(socket, &QTcpSocket::disconnected, this, [this, id] { destroyStream(id, "socket closed", true); }); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) connect(socket, &QTcpSocket::errorOccurred, this, [this, id](QAbstractSocket::SocketError error) { +#else + connect(socket, QOverload::of(&QAbstractSocket::error), this, + [this, id](QAbstractSocket::SocketError error) { +#endif Q_UNUSED(error) Stream *stream = findStream(id); if (!stream) diff --git a/src/lib/cooperation/core/net/helper/sharehelper.cpp b/src/lib/cooperation/core/net/helper/sharehelper.cpp index be8a94be1..ac77b64a6 100644 --- a/src/lib/cooperation/core/net/helper/sharehelper.cpp +++ b/src/lib/cooperation/core/net/helper/sharehelper.cpp @@ -706,8 +706,14 @@ void ShareHelperPrivate::probeBarrierServer(const QString &ip, int attemptsLeft) startClientBarrier(); }); + // Error handling function +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) connect(socket, &QTcpSocket::errorOccurred, this, [this, ip, attemptsLeft, finish](QAbstractSocket::SocketError error) { +#else + connect(socket, QOverload::of(&QAbstractSocket::error), this, + [this, ip, attemptsLeft, finish](QAbstractSocket::SocketError error) { +#endif Q_UNUSED(error) if (!finish()) return;