[qt] Drop support for Qt5 and update to Qt 6.8.1 (#3138)

This commit is contained in:
Tadej Novak
2025-01-14 06:45:33 +01:00
committed by GitHub
parent 20f1a03c91
commit 79d625b03c
10 changed files with 17 additions and 126 deletions

View File

@@ -1,5 +0,0 @@
FROM ghcr.io/maplibre/linux-builder:centos7-gcc11
# Copy and set the entry point
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -1,6 +0,0 @@
# action.yml
name: 'Qt5 Linux Builder'
description: 'Helper action to build in a specific Docker container'
runs:
using: 'docker'
image: 'Dockerfile'

View File

@@ -1,19 +0,0 @@
#!/bin/bash -l
source scl_source enable devtoolset-11 rh-git218
set -e
set -x
export CCACHE_DIR="$GITHUB_WORKSPACE/.ccache"
export PATH="$QT_ROOT_DIR/bin:$PATH"
mkdir build && cd build
cmake ../source/ \
-G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DMLN_WITH_QT=ON \
-DMLN_QT_IGNORE_ICU=OFF
ninja

View File

@@ -60,64 +60,40 @@ jobs:
matrix: matrix:
include: include:
- name: Linux - name: Linux
os: ubuntu-22.04 os: ubuntu-24.04
build_type: RelWithDebInfo build_type: RelWithDebInfo
qt_version: 5.15.2 qt_version: 6.8.1
qt_target: desktop
compiler: ""
- name: Linux
os: ubuntu-22.04
build_type: RelWithDebInfo
qt_version: 6.7.0
qt_target: desktop qt_target: desktop
compiler: "" compiler: ""
- name: Linux_GCC13 - name: Linux_GCC13
os: ubuntu-24.04 os: ubuntu-24.04
build_type: RelWithDebInfo build_type: RelWithDebInfo
qt_version: 6.7.0 qt_version: 6.8.1
qt_target: desktop qt_target: desktop
compiler: "gcc-13" compiler: "gcc-13"
- name: macOS
os: macos-13
build_type: RelWithDebInfo
qt_version: 5.15.2
qt_target: desktop
deployment_target: 10.15
deployment_arch: "x86_64"
compiler: ""
- name: macOS - name: macOS
os: macos-14 os: macos-14
build_type: RelWithDebInfo build_type: RelWithDebInfo
qt_version: 6.7.0 qt_version: 6.8.1
qt_target: desktop qt_target: desktop
deployment_target: 11.0 deployment_target: 12.0
deployment_arch: "x86_64;arm64" deployment_arch: "x86_64;arm64"
compiler: "" compiler: ""
- name: macOS_LLVM18 - name: macOS_LLVM
os: macos-14 os: macos-14
build_type: RelWithDebInfo build_type: RelWithDebInfo
qt_version: 6.7.0 qt_version: 6.8.1
qt_target: desktop qt_target: desktop
deployment_target: 11.0 deployment_target: 12.0
deployment_arch: "arm64" deployment_arch: "arm64"
compiler: "llvm" compiler: "llvm"
- name: win64_msvc2019 - name: win64_msvc2022
os: windows-2022 os: windows-2022
build_type: "RelWithDebInfo" build_type: "RelWithDebInfo"
compiler_type: x64 compiler_type: x64
compiler_version: 14.29 qt_version: 6.8.1
qt_version: 5.15.2
qt_target: desktop qt_target: desktop
qt_arch: win64_msvc2019_64 qt_arch: win64_msvc2022_64
qt_tools: ""
- name: win64_msvc2019
os: windows-2022
build_type: "RelWithDebInfo"
compiler_type: x64
compiler_version: 14.29
qt_version: 6.7.0
qt_target: desktop
qt_arch: win64_msvc2019_64
qt_tools: "" qt_tools: ""
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
@@ -200,11 +176,10 @@ jobs:
xcode-version: latest-stable xcode-version: latest-stable
- name: Setup MSVC - name: Setup MSVC
if: matrix.qt_arch == 'win64_msvc2019_64' if: matrix.qt_arch == 'win64_msvc2022_64'
uses: ilammy/msvc-dev-cmd@v1 uses: ilammy/msvc-dev-cmd@v1
with: with:
arch: ${{ matrix.compiler_type }} arch: ${{ matrix.compiler_type }}
toolset: ${{ matrix.compiler_version }}
- name: Setup ninja - name: Setup ninja
uses: seanmiddleditch/gha-setup-ninja@v5 uses: seanmiddleditch/gha-setup-ninja@v5
@@ -220,15 +195,6 @@ jobs:
tools: ${{ matrix.qt_tools }} tools: ${{ matrix.qt_tools }}
extra: --base https://mirrors.ocf.berkeley.edu/qt/ extra: --base https://mirrors.ocf.berkeley.edu/qt/
- name: Update ccache
if: runner.os == 'Windows'
shell: bash
run: |
# version is pinned due to issues with caching MSVC in 4.8
choco.exe install ccache --version=4.7.5 --no-progress
ccache.exe --version
echo "CCACHE_CONFIGPATH=C:/Users/runneradmin/AppData/Roaming/ccache/ccache.conf" >> "$GITHUB_ENV"
- name: Set up ccache - name: Set up ccache
uses: hendrikmuhs/ccache-action@v1 uses: hendrikmuhs/ccache-action@v1
with: with:
@@ -249,16 +215,12 @@ jobs:
-DMLN_WITH_QT=ON -DMLN_WITH_QT=ON
ninja ninja
- name: Build maplibre-native (Linux, Qt5)
if: runner.os == 'Linux' && matrix.qt_version == '5.15.2'
uses: ./source/.github/actions/qt5-build
- name: Build maplibre-native (Linux, Qt6) - name: Build maplibre-native (Linux, Qt6)
if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler == '' if: runner.os == 'Linux' && matrix.compiler == ''
uses: ./source/.github/actions/qt6-build uses: ./source/.github/actions/qt6-build
- name: Build maplibre-native (Linux, Qt6, custom compiler) - name: Build maplibre-native (Linux, Qt6, custom compiler)
if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler != '' if: runner.os == 'Linux' && matrix.compiler != ''
run: | run: |
mkdir build && cd build mkdir build && cd build
qt-cmake ../source/ \ qt-cmake ../source/ \
@@ -270,7 +232,7 @@ jobs:
ninja ninja
- name: Build maplibre-native (Linux, Qt6, custom compiler, internal libraries) - name: Build maplibre-native (Linux, Qt6, custom compiler, internal libraries)
if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler != '' if: runner.os == 'Linux' && matrix.compiler != ''
run: | run: |
mkdir build-internal && cd build-internal mkdir build-internal && cd build-internal
qt-cmake ../source/ \ qt-cmake ../source/ \
@@ -284,7 +246,7 @@ jobs:
ninja ninja
- name: Run tests (Linux) - name: Run tests (Linux)
if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler != '' if: runner.os == 'Linux' && matrix.compiler != ''
uses: coactions/setup-xvfb@v1 uses: coactions/setup-xvfb@v1
with: with:
run: ctest --output-on-failure run: ctest --output-on-failure

View File

@@ -32,7 +32,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif() endif()
if("${QT_VERSION_MAJOR}" STREQUAL "") if("${QT_VERSION_MAJOR}" STREQUAL "")
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) find_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)
else() else()
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
endif() endif()

View File

@@ -30,21 +30,10 @@ void HTTPFileSource::Impl::request(HTTPRequest* req) {
} }
QNetworkRequest networkRequest = req->networkRequest(); QNetworkRequest networkRequest = req->networkRequest();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
networkRequest.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
#elif QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
#endif
data.first = m_manager->get(networkRequest); data.first = m_manager->get(networkRequest);
connect(data.first, &QNetworkReply::finished, this, &HTTPFileSource::Impl::onReplyFinished); connect(data.first, &QNetworkReply::finished, this, &HTTPFileSource::Impl::onReplyFinished);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(data.first, &QNetworkReply::errorOccurred, this, &HTTPFileSource::Impl::onReplyFinished); connect(data.first, &QNetworkReply::errorOccurred, this, &HTTPFileSource::Impl::onReplyFinished);
#else
connect(data.first, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyFinished()));
#endif
} }
void HTTPFileSource::Impl::cancel(HTTPRequest* req) { void HTTPFileSource::Impl::cancel(HTTPRequest* req) {

View File

@@ -43,13 +43,8 @@ PremultipliedImage decodeImage(const std::string& string) {
throw std::runtime_error("Unsupported image type"); throw std::runtime_error("Unsupported image type");
} }
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
auto img = std::make_unique<uint8_t[]>(image.sizeInBytes()); auto img = std::make_unique<uint8_t[]>(image.sizeInBytes());
memcpy(img.get(), image.constBits(), image.sizeInBytes()); memcpy(img.get(), image.constBits(), image.sizeInBytes());
#else
auto img = std::make_unique<uint8_t[]>(image.byteCount());
memcpy(img.get(), image.constBits(), image.byteCount());
#endif
return {{static_cast<uint32_t>(image.width()), static_cast<uint32_t>(image.height())}, std::move(img)}; return {{static_cast<uint32_t>(image.width()), static_cast<uint32_t>(image.height())}, std::move(img)};
} }

View File

@@ -53,11 +53,7 @@ Glyph LocalGlyphRasterizer::rasterizeGlyph(const FontStack&, GlyphID glyphID) {
return glyph; return glyph;
} }
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
glyph.metrics.width = impl->metrics->horizontalAdvance(glyphID); glyph.metrics.width = impl->metrics->horizontalAdvance(glyphID);
#else
glyph.metrics.width = impl->metrics->width(glyphID);
#endif
glyph.metrics.height = impl->metrics->height(); glyph.metrics.height = impl->metrics->height();
glyph.metrics.left = 3; glyph.metrics.left = 3;
glyph.metrics.top = -8; glyph.metrics.top = -8;
@@ -73,13 +69,8 @@ Glyph LocalGlyphRasterizer::rasterizeGlyph(const FontStack&, GlyphID glyphID) {
// Render at constant baseline, to align with glyphs that are rendered by node-fontnik. // Render at constant baseline, to align with glyphs that are rendered by node-fontnik.
painter.drawText(QPointF(0, 20), QString(QChar(glyphID))); painter.drawText(QPointF(0, 20), QString(QChar(glyphID)));
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
auto img = std::make_unique<uint8_t[]>(image.sizeInBytes()); auto img = std::make_unique<uint8_t[]>(image.sizeInBytes());
memcpy(img.get(), image.constBits(), image.sizeInBytes()); memcpy(img.get(), image.constBits(), image.sizeInBytes());
#else
auto img = std::make_unique<uint8_t[]>(image.byteCount());
memcpy(img.get(), image.constBits(), image.byteCount());
#endif
glyph.bitmap = AlphaImage{size, std::move(img)}; glyph.bitmap = AlphaImage{size, std::move(img)};

View File

@@ -169,11 +169,7 @@ void Database::exec(const std::string& sql) {
} }
void DatabaseImpl::exec(const std::string& sql) { void DatabaseImpl::exec(const std::string& sql) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList statements = QString::fromStdString(sql).split(';', Qt::SkipEmptyParts); QStringList statements = QString::fromStdString(sql).split(';', Qt::SkipEmptyParts);
#else
QStringList statements = QString::fromStdString(sql).split(';', QString::SkipEmptyParts);
#endif
statements.removeAll("\n"); statements.removeAll("\n");
for (QString statement : statements) { for (QString statement : statements) {
if (!statement.endsWith(';')) { if (!statement.endsWith(';')) {
@@ -233,11 +229,7 @@ template <>
void Query::bind(int offset, std::nullptr_t) { void Query::bind(int offset, std::nullptr_t) {
assert(stmt.impl); assert(stmt.impl);
// Field numbering starts at 0. // Field numbering starts at 0.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
stmt.impl->query.bindValue(offset - 1, QVariant(), QSql::In); stmt.impl->query.bindValue(offset - 1, QVariant(), QSql::In);
#else
stmt.impl->query.bindValue(offset - 1, QVariant(QVariant::Invalid), QSql::In);
#endif
checkQueryError(stmt.impl->query); checkQueryError(stmt.impl->query);
} }

View File

@@ -18,11 +18,7 @@ void Timer::Impl::start(uint64_t timeout, uint64_t repeat_, std::function<void()
callback = std::move(cb); callback = std::move(cb);
timer.setSingleShot(true); timer.setSingleShot(true);
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
timer.start(static_cast<std::chrono::milliseconds>(timeout)); timer.start(static_cast<std::chrono::milliseconds>(timeout));
#else
timer.start(static_cast<int>(timeout));
#endif
} }
void Timer::Impl::stop() { void Timer::Impl::stop() {
@@ -32,11 +28,7 @@ void Timer::Impl::stop() {
void Timer::Impl::timerFired() { void Timer::Impl::timerFired() {
if (repeat) { if (repeat) {
timer.setSingleShot(false); timer.setSingleShot(false);
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
timer.start(static_cast<std::chrono::milliseconds>(repeat)); timer.start(static_cast<std::chrono::milliseconds>(repeat));
#else
timer.start(static_cast<int>(repeat));
#endif
} }
callback(); callback();