Skip to content

Commit

Permalink
Merge PR #6516: Switch to Qt 6 and C++17
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici authored Sep 19, 2024
2 parents 82f1c30 + de91daa commit 7101060
Show file tree
Hide file tree
Showing 123 changed files with 681 additions and 475 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ environment:

matrix:
- MUMBLE_ENVIRONMENT_TRIPLET: 'x64-windows-static-md-release'
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-windows-static-md-release.2023-12-31.6a3ce9c65'
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-windows-static-md-release.2024-07-22.9ad0398d8'

install:
- ps: .ci/install-environment_windows.ps1
Expand Down
10 changes: 6 additions & 4 deletions .ci/azure-pipelines/install-environment_linux.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ sudo apt -y install \
g++-multilib \
ninja-build \
pkg-config \
qtbase5-dev \
qttools5-dev \
qttools5-dev-tools \
libqt5svg5-dev \
qt6-base-dev \
qt6-l10n-tools \
qt6-tools-dev \
qt6-tools-dev-tools \
libqt6svg6-dev \
libgl-dev \
libboost-dev \
libssl-dev \
libprotobuf-dev \
Expand Down
4 changes: 2 additions & 2 deletions .ci/azure-pipelines/main-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
pool:
vmImage: 'windows-2022'
variables:
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-windows-static-md-release.2023-12-31.6a3ce9c65'
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-windows-static-md-release.2024-07-22.9ad0398d8'
MUMBLE_ENVIRONMENT_TRIPLET: 'x64-windows-static-md-release'
steps:
- template: steps_windows.yml
Expand All @@ -45,7 +45,7 @@ jobs:
pool:
vmImage: 'macOS-12'
variables:
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-osx-release.2023-12-31.6a3ce9c65'
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-osx-release.2024-08-17.9ad0398d8'
MUMBLE_ENVIRONMENT_TRIPLET: 'x64-osx-release'
steps:
- template: steps_macos.yml
Expand Down
4 changes: 2 additions & 2 deletions .ci/azure-pipelines/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
pool:
vmImage: 'windows-2022'
variables:
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-windows-static-md-release.2023-12-31.6a3ce9c65'
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-windows-static-md-release.2024-07-22.9ad0398d8'
MUMBLE_ENVIRONMENT_TRIPLET: 'x64-windows-static-md-release'
steps:
- template: steps_windows.yml
Expand All @@ -43,7 +43,7 @@ jobs:
pool:
vmImage: 'macOS-12'
variables:
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-osx-release.2023-12-31.6a3ce9c65'
MUMBLE_ENVIRONMENT_VERSION: 'mumble_env.x64-osx-release.2024-08-17.9ad0398d8'
MUMBLE_ENVIRONMENT_TRIPLET: 'x64-osx-release'
steps:
- template: steps_macos.yml
Expand Down
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ freebsd_instance:
freebsd_task:
pkg_script:
- pkg update && pkg upgrade -y
- pkg install -y git ninja pkgconf cmake qt5-buildtools qt5-qmake qt5-linguisttools qt5-concurrent qt5-network qt5-xml qt5-sql qt5-svg qt5-testlib boost-libs libsndfile protobuf ice37 avahi-libdns poco opus
- pkg install -y git ninja pkgconf cmake qt6-base qt6-svg qt6-tools boost-libs libsndfile protobuf ice37 avahi-libdns poco opus
fetch_submodules_script: git submodule --quiet update --init --recursive
build_script:
- mkdir build && cd build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env bash

. /etc/os-release

sudo apt update

sudo apt -y install \
build-essential \
g++-multilib \
ninja-build \
pkg-config \
qtbase5-dev \
qttools5-dev \
qttools5-dev-tools \
libqt5svg5-dev \
qt6-base-dev \
qt6-tools-dev \
libboost-dev \
libssl-dev \
libprotobuf-dev \
Expand All @@ -30,3 +30,17 @@ sudo apt -y install \
zsync \
appstream \
libpoco-dev

# The package was initially called libqt6svg6-dev.
# Choose correct name based on the Ubuntu version.
if [[ $VERSION_ID = "22.04" ]]
then
# libgl-dev is required in order for GUI-related components to be found by CMake.
# qt6-l10n-tools and qt6-tools-dev-tools are required in order for LinguistTools to be found by CMake.
sudo apt -y install libgl-dev \
libqt6svg6-dev \
qt6-l10n-tools \
qt6-tools-dev-tools
else
sudo apt -y install qt6-svg-dev
fi
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ list(APPEND CMAKE_MODULE_PATH
)

if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)


include(pkg-utils)
Expand Down
3 changes: 0 additions & 3 deletions cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ if(MSVC)
"/ignore:4099"
)
endif()

# Workaround for MSVC 17.8 breaking change. (fixed in Qt 5.15.17)
add_compile_definitions(_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING)
elseif(UNIX OR MINGW)
add_compile_options(
"-fvisibility=hidden"
Expand Down
10 changes: 0 additions & 10 deletions cmake/os.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,11 @@ else()
endif()

find_pkg(OpenSSL QUIET)
find_pkg(Qt5 QUIET)

if(NOT OpenSSL_FOUND)
if(APPLE)
# Homebrew
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
endif()

if(NOT Qt5_FOUND)
if(APPLE)
# Homebrew
set(Qt5_DIR "/usr/local/opt/qt5/lib/cmake/Qt5")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
set(Qt5_DIR "/usr/local/lib/qt5/cmake/Qt5")
endif()
endif()
endif()
6 changes: 3 additions & 3 deletions cmake/qt-utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function(include_qt_plugin TARGET SCOPE PLUGIN)
endfunction()

function(compile_translations OUT_VAR OUT_DIR TS_FILES)
find_pkg(Qt5 COMPONENTS LinguistTools REQUIRED)
find_pkg(Qt6 COMPONENTS LinguistTools REQUIRED)

# Create output directory
file(MAKE_DIRECTORY "${OUT_DIR}")
Expand All @@ -47,7 +47,7 @@ function(compile_translations OUT_VAR OUT_DIR TS_FILES)
# Compile the given .ts files into .qm files into the output directory
foreach(CURRENT_TS IN LISTS TS_FILES)
set_source_files_properties("${CURRENT_TS}" PROPERTIES OUTPUT_LOCATION "${OUT_DIR}")
qt5_add_translation(COMPILED_FILES "${CURRENT_TS}")
qt6_add_translation(COMPILED_FILES "${CURRENT_TS}")
endforeach()

# return the list of compiled .qm files
Expand Down Expand Up @@ -96,7 +96,7 @@ endfunction()

function(query_qmake OUT_VAR PROP)
# Get the path to the qmake executable
get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
get_target_property(QT_QMAKE_EXECUTABLE Qt6::qmake IMPORTED_LOCATION)

# Query qmake for the location of the installed Qt translations
execute_process(
Expand Down
8 changes: 4 additions & 4 deletions helpers/g15helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ set_target_properties(g15-helper
target_compile_definitions(g15-helper PRIVATE $<$<CONFIG:Debug>:USE_LOGFILE>)

if(g15-emulator)
find_pkg(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
find_pkg(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
set_target_properties(g15-helper PROPERTIES AUTOMOC ON)
target_sources(g15-helper PRIVATE "g15helper_emu.cpp" "g15helper_emu.h")
target_link_libraries(g15-helper PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets)
target_link_libraries(g15-helper PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets)

if(static AND WIN32 AND TARGET Qt5::QWindowsIntegrationPlugin)
if(static AND WIN32 AND TARGET Qt6::QWindowsIntegrationPlugin)
include_qt_plugin(g15-helper PRIVATE QWindowsIntegrationPlugin)
target_link_libraries(g15-helper PRIVATE Qt5::QWindowsIntegrationPlugin)
target_link_libraries(g15-helper PRIVATE Qt6::QWindowsIntegrationPlugin)
endif()
else()
if(MSVC)
Expand Down
2 changes: 1 addition & 1 deletion src/Ban.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ QString Ban::toString() const {
iDuration == 0 ? QLatin1String("(permanent)") : QLatin1String("(temporary)"));
}

quint32 qHash(const Ban &b) {
std::size_t qHash(const Ban &b) {
return qHash(b.qsHash) ^ qHash(b.haAddress) ^ qHash(b.qsUsername) ^ qHash(b.iMask);
}
2 changes: 1 addition & 1 deletion src/Ban.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ struct Ban {
QString toString() const;
};

quint32 qHash(const Ban &);
std::size_t qHash(const Ban &);

#endif
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ option(tracy "Enable the tracy profiler." OFF)
option(bundled-gsl "Use the bundled GSL version instead of looking for one on the system" ON)


find_pkg(Qt5
find_pkg(Qt6
COMPONENTS
Core
Network
Expand Down Expand Up @@ -176,9 +176,9 @@ target_link_libraries(shared
protobuf::libprotobuf
OpenSSL::Crypto
OpenSSL::SSL
Qt5::Core
Qt5::Network
Qt5::Xml
Qt6::Core
Qt6::Network
Qt6::Xml
)

if(WIN32)
Expand Down
4 changes: 2 additions & 2 deletions src/ChannelListenerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ const QSet< unsigned int > ChannelListenerManager::getListenedChannelsForUser(un
int ChannelListenerManager::getListenerCountForChannel(unsigned int channelID) const {
QReadLocker lock(&m_listenerLock);

return m_listenedChannels[channelID].size();
return static_cast< int >(m_listenedChannels[channelID].size());
}

int ChannelListenerManager::getListenedChannelCountForUser(unsigned int userSession) const {
QReadLocker lock(&m_listenerLock);

return m_listeningUsers[userSession].size();
return static_cast< int >(m_listeningUsers[userSession].size());
}

void ChannelListenerManager::setListenerVolumeAdjustment(unsigned int userSession, unsigned int channelID,
Expand Down
2 changes: 1 addition & 1 deletion src/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Connection::Connection(QObject *p, QSslSocket *qtsSock) : QObject(p) {
setsockopt(static_cast< int >(qtsSocket->socketDescriptor()), IPPROTO_TCP, TCP_NODELAY,
reinterpret_cast< char * >(&nodelay), static_cast< socklen_t >(sizeof(nodelay)));

connect(qtsSocket, SIGNAL(error(QAbstractSocket::SocketError)), this,
connect(qtsSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this,
SLOT(socketError(QAbstractSocket::SocketError)));
connect(qtsSocket, SIGNAL(encrypted()), this, SIGNAL(encrypted()));
connect(qtsSocket, SIGNAL(readyRead()), this, SLOT(socketRead()));
Expand Down
5 changes: 2 additions & 3 deletions src/FFDHE.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#ifndef MUMBLE_FFDHE_H_
#define MUMBLE_FFDHE_H_

class QByteArray;
class QString;
class QStringList;
#include <QByteArray>
#include <QStringList>

/// FFDHE provides access to the Diffie-Hellman parameters from RFC 7919.
class FFDHE {
Expand Down
8 changes: 4 additions & 4 deletions src/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool Group::appliesToUser(const Channel &currentChannel, const Channel &aclChann
channel = channel->cParent;
}

int requiredChannelIndex = currentChannelHierarchy.indexOf(contextChannel);
auto requiredChannelIndex = currentChannelHierarchy.indexOf(contextChannel);
Q_ASSERT(requiredChannelIndex != -1);

requiredChannelIndex += requiredChannelOffset;
Expand All @@ -211,10 +211,10 @@ bool Group::appliesToUser(const Channel &currentChannel, const Channel &aclChann
return RET_FALSE;
}

const int minDepth = requiredChannelIndex + minDescendantLevel;
const int maxDepth = requiredChannelIndex + maxDescendantLevel;
const auto minDepth = requiredChannelIndex + minDescendantLevel;
const auto maxDepth = requiredChannelIndex + maxDescendantLevel;

const int totalDepth = homeChannelHierarchy.count() - 1;
const auto totalDepth = homeChannelHierarchy.count() - 1;

matches = (totalDepth >= minDepth) && (totalDepth <= maxDepth);
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/HostAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "ByteSwap.h"

#include <QRegularExpression>

#ifdef Q_OS_WIN
# include "win.h"
# include <winsock2.h>
Expand Down Expand Up @@ -180,7 +182,7 @@ void HostAddress::setByte(std::size_t idx, std::uint8_t value) {
m_byteRepresentation[idx] = value;
}

quint32 qHash(const HostAddress &ha) {
std::size_t qHash(const HostAddress &ha) {
return qHashRange(ha.m_byteRepresentation.begin(), ha.m_byteRepresentation.end());
}

Expand All @@ -202,7 +204,7 @@ QString HostAddress::toString(bool bracketEnclosed) const {
ntohs(shortArray[4]), ntohs(shortArray[5]), ntohs(shortArray[6]),
ntohs(shortArray[7]), squareBracketClose);

return str.replace(QRegExp(QLatin1String("(:0)+")), QLatin1String(":"));
return str.replace(QRegularExpression(QLatin1String("(:0)+")), QLatin1String(":"));
} else {
return bracketEnclosed ? QLatin1String("[::]") : QLatin1String("::");
}
Expand Down
2 changes: 1 addition & 1 deletion src/HostAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct HostAddress {

void setByte(std::size_t idx, std::uint8_t value);

friend quint32 qHash(const HostAddress &);
friend std::size_t qHash(const HostAddress &);

private:
// Binary representation of an IPv6 address
Expand Down
2 changes: 1 addition & 1 deletion src/OSInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ QString OSInfo::getOSVersion() {
if (err == noErr)
err = Gestalt(gestaltSystemVersionBugFix, &bugfix);
if (err != noErr)
return QString::number(QSysInfo::MacintoshVersion, 16);
return QSysInfo::productVersion();

char *buildno = nullptr;
char buildno_buf[32];
Expand Down
2 changes: 1 addition & 1 deletion src/PacketDataStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class PacketDataStream {
return *this; \
}


INTMAPOPERATOR(qsizetype);
INTMAPOPERATOR(int);
INTMAPOPERATOR(unsigned int);
INTMAPOPERATOR(short);
Expand Down
6 changes: 3 additions & 3 deletions src/ProcessResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ void ProcessResolver::doResolve() {
QByteArray cmdline = f.readAll();
f.close();

int nul = cmdline.indexOf('\0');
const auto nul = cmdline.indexOf('\0');
if (nul != -1) {
cmdline.truncate(nul);
}

QString exe = QString::fromUtf8(cmdline);
if (exe.contains(QLatin1String("\\"))) {
int lastBackslash = exe.lastIndexOf(QLatin1String("\\"));
if (exe.count() > lastBackslash + 1) {
const auto lastBackslash = exe.lastIndexOf(QLatin1String("\\"));
if (exe.length() > lastBackslash + 1) {
baseName = exe.mid(lastBackslash + 1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/QtUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

#include <QCryptographicHash>
#include <QString>
#include <QStringList>

#include <memory>

class QObject;
class QStringList;

namespace Mumble {
namespace QtUtils {
Expand Down
Loading

0 comments on commit 7101060

Please sign in to comment.