From 878a536f58c0094aa813d7396cbf2fc2caa31008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 15 Apr 2024 16:35:59 +0200 Subject: [PATCH 01/15] docs: Small fix to snippet converting from Qt.Url to string On Windows we need to remove three slashes. --- docs/scripting-doc/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/scripting-doc/index.d.ts b/docs/scripting-doc/index.d.ts index 3da2282c9a..c6042e6fe5 100644 --- a/docs/scripting-doc/index.d.ts +++ b/docs/scripting-doc/index.d.ts @@ -455,7 +455,7 @@ declare namespace Qt { * case you need a local file path, you can use the following code: * * ```js - * var path = url.toString().replace(/^file:\/{2}/, ''); + * var path = url.toString().replace(/^file:\/{3}/, (tiled.platform == 'windows') ? '' : '/');; * ``` * * Or have a look at whether an alternative property is available that From 8027f07cbcfd2c31b4c30aecbde4ab97f124c231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 18 Apr 2024 13:21:01 +0200 Subject: [PATCH 02/15] snap: Fixed determining of the version (#3926) When using the 'version: git' approach, only the final snap knows the version, but it isn't known yet at compile time so Tiled always shows its version as "git". Setting fetch-depth to 0 makes it fetch all history for all branches and tags, which is needed for `git describe` to work. --- .github/workflows/packages.yml | 3 ++- snap/snapcraft.yaml | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index fb27afa5a8..87fea37252 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -154,11 +154,12 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set Tiled version id: version run: | - sed -i 's/^version: .*/version: '"${TILED_VERSION}"'/g' snap/snapcraft.yaml if [[ "$TILED_RELEASE" == 'true' ]]; then echo "snap_channel=candidate" >> $GITHUB_OUTPUT ; fi if [[ "$TILED_RELEASE" != 'true' ]]; then echo "snap_channel=beta" >> $GITHUB_OUTPUT ; fi diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 027dbc80b3..03e8c4b06d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,5 @@ name: tiled adopt-info: tiled -version: git license: GPL-2.0 base: core22 @@ -44,10 +43,13 @@ apps: parts: tiled: plugin: make + override-pull: | + craftctl default + craftctl set version="$(git describe | sed 's/v//')" override-build: | - qbs setup-toolchains --detect - qbs build --jobs "${CRAFT_PARALLEL_BUILD_COUNT}" --command-echo-mode command-line config:release qbs.installPrefix:"/usr" projects.Tiled.version:$(craftctl get version) projects.Tiled.useRPaths:false - qbs install --install-root "${CRAFT_PART_INSTALL}" config:release + qbs setup-toolchains --detect + qbs build --jobs "${CRAFT_PARALLEL_BUILD_COUNT}" --command-echo-mode command-line config:release qbs.installPrefix:"/usr" projects.Tiled.version:$(craftctl get version) projects.Tiled.useRPaths:false + qbs install --install-root "${CRAFT_PART_INSTALL}" config:release parse-info: - usr/share/metainfo/org.mapeditor.Tiled.appdata.xml source: . From 3e60f79e31e84683a8b9ea5eaac9e559c34b95c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 28 Mar 2024 20:35:34 +0100 Subject: [PATCH 03/15] GitHub Actions: Updated to Qt 6.7.0 --- .github/workflows/packages.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 87fea37252..d4a063567b 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -48,7 +48,7 @@ jobs: include: - qt_version: 5.15.2 qt_version_major: 5 - - qt_version: 6.6.2 + - qt_version: 6.7.0 qt_version_major: 6 env: @@ -193,7 +193,7 @@ jobs: - qt_version: 5.12.12 version_suffix: "10.12-10.15" architectures: x86_64 - - qt_version: 6.6.2 + - qt_version: 6.7.0 version_suffix: "11+" architectures: x86_64,arm64 @@ -285,7 +285,7 @@ jobs: mingw_version: 8.1.0 mingw_component: mingw mingw_path: /c/Qt/Tools/mingw810_32/bin - - qt_version: 6.6.2 + - qt_version: 6.7.0 qt_version_major: 6 qt_toolchain: win64_mingw arch: 64 From 3be0a652226e047c762d448253170afb74235f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 10 Apr 2024 15:38:33 +0200 Subject: [PATCH 04/15] Fixed install-qt.sh for downloading Qt 6.7.0 The name of the toolchain changed. --- dist/install-qt.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dist/install-qt.sh b/dist/install-qt.sh index 25f3463b3f..5e544ee23e 100755 --- a/dist/install-qt.sh +++ b/dist/install-qt.sh @@ -250,6 +250,10 @@ done DOWNLOAD_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'install-qt'` +function version { + echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; +} + # # The repository structure is a mess. Try different URL variants # @@ -293,6 +297,12 @@ function compute_url(){ return 0 fi else + if [ "$(version "${VERSION}")" -ge "$(version "6.7.0")" ]; then + if [ "${TOOLCHAIN}" == "gcc_64" ]; then + TOOLCHAIN="linux_gcc_64" + fi + fi + REMOTE_BASES=( # New repository format (>=6.0.0) "qt6_${VERSION//./}/qt.qt6.${VERSION//./}.${TOOLCHAIN}" @@ -324,10 +334,6 @@ function compute_url(){ exit 1 } -function version { - echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; -} - mkdir -p ${INSTALL_DIR} rm -f "${HASH_FILEPATH}" From e88b6d70148a4e318532b842f4fcf35226339ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 17 Apr 2024 15:43:26 +0200 Subject: [PATCH 05/15] Fixed Windows installer for Qt 6.7 Now there is a Modern Windows style plugin rather than a Windows Vista plugin. --- dist/win/installer.qbs | 5 ++++- dist/win/installer.wxs | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/win/installer.qbs b/dist/win/installer.qbs index 3ad5e84a43..73bc84fb5f 100644 --- a/dist/win/installer.qbs +++ b/dist/win/installer.qbs @@ -52,7 +52,10 @@ WindowsInstallerPackage { } } - defs.push("WindowsVistaStyle") + if (Qt.core.versionMajor >= 6 && Qt.core.versionMinor >= 7) + defs.push("WindowsStylePlugin=qmodernwindowsstyle.dll") + else + defs.push("WindowsStylePlugin=qwindowsvistastyle.dll") var pythonHome = Environment.getEnv("PYTHONHOME"); if (pythonHome && File.exists(pythonHome)) diff --git a/dist/win/installer.wxs b/dist/win/installer.wxs index 3205901904..ba7a97a7ec 100644 --- a/dist/win/installer.wxs +++ b/dist/win/installer.wxs @@ -203,10 +203,10 @@ - + - + @@ -448,7 +448,7 @@ - + = 6 and $(var.QtVersionMinor) >= 2 ?> From 93f6fef14052e6797440e3f4c4a093f7507b2249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 17 Apr 2024 22:10:59 +0200 Subject: [PATCH 06/15] Qt 6.7: Fixed group box rendering Broke due to a change in Fusion style regarding where the frame group box rect was calculated (be03e8523df3922d4f8987db8f1ca7293b63f6a2). --- src/tiled/tiledproxystyle.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tiled/tiledproxystyle.cpp b/src/tiled/tiledproxystyle.cpp index 2c6f426bb2..c67f882f13 100644 --- a/src/tiled/tiledproxystyle.cpp +++ b/src/tiled/tiledproxystyle.cpp @@ -20,11 +20,16 @@ #include "tiledproxystyle.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #include "utils.h" +#endif #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0) +#include +#endif #include #include #include @@ -351,7 +356,17 @@ void TiledProxyStyle::drawPrimitive(PrimitiveElement element, switch (element) { case PE_FrameGroupBox: { - int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + 3; + int topMargin = 0; +#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0) + auto control = qobject_cast(widget); + if (control && !control->isCheckable() && control->title().isEmpty()) { + // Shrinking the topMargin if Not checkable AND title is empty + topMargin = 3; + } else { + topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), + option->fontMetrics.height()) + 3; + } +#endif QRect frame = option->rect.adjusted(0, topMargin, -1, -1); QColor tabFrameColor = getTabFrameColor(option->palette); From 3285e95a658ceba9b46ed0af24b0d916a741ea8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 18 Apr 2024 13:11:17 +0200 Subject: [PATCH 07/15] AppVeyor: Updated Windows builds to Qt 6.7 --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5d16ea8a55..534c12c926 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,12 +12,12 @@ environment: BUTLER_API_KEY: secure: j7JM5L6KeqpnQukzJLsm7J6oV92SpmyEZLSoED1pZ3gQ79VIkdxtbQmTkqUNZPsz matrix: - - QTDIR: C:\Qt\6.4\msvc2019_64 + - QTDIR: C:\Qt\6.7\msvc2019_64 PYTHONHOME: C:\Python38-x64 DEFAULT_PROFILE: MSVC2019-x64 PUSH_RELEASE: false ENABLE_ZSTD: false - - QTDIR: C:\Qt\6.4\mingw_64 + - QTDIR: C:\Qt\6.7\mingw_64 PYTHONHOME: C:\Python38-x64 MINGW: C:\Qt\Tools\mingw1120_64 DEFAULT_PROFILE: x86_64-w64-mingw32-gcc-11_2_0 From 4862b5119ae229963b074d1b5b3ce5f96eb1af8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 18 Apr 2024 14:50:55 +0200 Subject: [PATCH 08/15] AppImage: Fixed ability to launch without parameters After fixing the "is string non-empty" check in de5373af22885e2e75692c0, the script no longer did anything when no parameter was given... As far as I could see, this check should just be removed. See #3914 --- dist/linux/AppRun | 54 ++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/dist/linux/AppRun b/dist/linux/AppRun index b77de5474d..945c0b3a1c 100644 --- a/dist/linux/AppRun +++ b/dist/linux/AppRun @@ -27,32 +27,28 @@ my_help() { echo "Tiled help:" } -if [ -n "${1}" ] -then - case ${1} in - terraingenerator) - shift - exec "$this_dir"/${bin_dir}/terraingenerator "$@" - ;; - tiled) - shift - exec "$this_dir"/${bin_dir}/tiled "$@" - ;; - tmxrasterizer) - shift - exec "$this_dir"/${bin_dir}/tmxrasterizer "$@" - ;; - tmxviewer) - shift - exec "$this_dir"/${bin_dir}/tmxviewer "$@" - ;; - "--help") - my_help - exec "$this_dir"/${bin_dir}/tiled "--help" - ;; - *) - exec "$this_dir"/${bin_dir}/tiled "$@" - ;; - esac - -fi +case ${1} in + terraingenerator) + shift + exec "$this_dir"/${bin_dir}/terraingenerator "$@" + ;; + tiled) + shift + exec "$this_dir"/${bin_dir}/tiled "$@" + ;; + tmxrasterizer) + shift + exec "$this_dir"/${bin_dir}/tmxrasterizer "$@" + ;; + tmxviewer) + shift + exec "$this_dir"/${bin_dir}/tmxviewer "$@" + ;; + "--help") + my_help + exec "$this_dir"/${bin_dir}/tiled "--help" + ;; + *) + exec "$this_dir"/${bin_dir}/tiled "$@" + ;; +esac From cf21779e55f2ed25f1c36498d20646cbe412da17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 18 Apr 2024 15:13:01 +0200 Subject: [PATCH 09/15] Tweaked margin between group box header and contents 93f6fef14052e6797440e3f4c4a093f7507 had left it a little uncomfortable. --- src/tiled/tiledproxystyle.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tiled/tiledproxystyle.cpp b/src/tiled/tiledproxystyle.cpp index c67f882f13..0ba0f41ce0 100644 --- a/src/tiled/tiledproxystyle.cpp +++ b/src/tiled/tiledproxystyle.cpp @@ -356,15 +356,14 @@ void TiledProxyStyle::drawPrimitive(PrimitiveElement element, switch (element) { case PE_FrameGroupBox: { - int topMargin = 0; + int topMargin = 3; #if QT_VERSION < QT_VERSION_CHECK(6, 7, 0) auto control = qobject_cast(widget); if (control && !control->isCheckable() && control->title().isEmpty()) { // Shrinking the topMargin if Not checkable AND title is empty - topMargin = 3; } else { - topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), - option->fontMetrics.height()) + 3; + topMargin += qMax(pixelMetric(PM_ExclusiveIndicatorHeight), + option->fontMetrics.height()); } #endif QRect frame = option->rect.adjusted(0, topMargin, -1, -1); From a3768788cbb60b607f40805515d428e25abd83b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 10 Apr 2024 15:48:52 +0200 Subject: [PATCH 10/15] Updates to install-qt.sh merged from Qbs repository Nothing really relevant for Tiled, apart from the mirror removal. Just keeping the differences with upstream smaller. --- dist/install-qt.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/dist/install-qt.sh b/dist/install-qt.sh index 5e544ee23e..9105d321f5 100755 --- a/dist/install-qt.sh +++ b/dist/install-qt.sh @@ -45,7 +45,7 @@ usage: install-qt [options] [components] Examples ./install-qt.sh --version 5.13.1 qtbase - ./install-qt.sh --version 5.14.0 --target android --toolchain any qtbase qtscript + ./install-qt.sh --version 5.14.0 --target android --toolchain any qtbase Positional arguments components @@ -89,7 +89,7 @@ Options android any, android_armv7, android_arm64_v8a desktop - clang_64 (default), + clang_64 (default) ios ios @@ -234,7 +234,6 @@ fi MIRRORS="\ http://ftp.acc.umu.se/mirror/qt.io/qtproject \ - http://qt.mirrors.tds.net/qt \ http://ftp.fau.de/qtproject \ http://download.qt.io \ " @@ -379,7 +378,7 @@ for COMPONENT in ${COMPONENTS}; do SUBDIR="${TOOLCHAIN/win32_/}" elif [[ "${TOOLCHAIN}" =~ "any" ]] && [[ "${TARGET_PLATFORM}" == "android" ]]; then SUBDIR="android" - elif [ "${HOST_OS}" == "mac_x64" ] && [ ! "${VERSION}" \< "6.1.2" ]; then + elif [[ "${HOST_OS}" == "mac_x64" ]] && [[ ! "${VERSION}" < "6.1.2" ]] && [[ "${TARGET_PLATFORM}" == "desktop" ]]; then SUBDIR="macos" else SUBDIR="${TOOLCHAIN}" @@ -387,11 +386,25 @@ for COMPONENT in ${COMPONENTS}; do if [ "${TARGET_PLATFORM}" == "android" ] && [ ! "${VERSION}" \< "6.0.0" ]; then CONF_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/target_qt.conf" + ANDROID_QMAKE_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/qmake" + if [ "${TOOLCHAIN}" == "android_armv7" ] && [ ! "${VERSION}" \< "6.4.2" ]; then + sed -i "s/\r//" "${CONF_FILE}" + sed -i "s|HostLibraryExecutables=.\/bin|HostLibraryExecutables=.\/libexec|g" "${CONF_FILE}" + chmod +x "${ANDROID_QMAKE_FILE}" + sed -i "s|\\\|\/|g" "${ANDROID_QMAKE_FILE}" + fi sed -i "s|target|../$TOOLCHAIN|g" "${CONF_FILE}" sed -i "/HostPrefix/ s|$|gcc_64|g" "${CONF_FILE}" - ANDROID_QMAKE_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/qmake" QMAKE_FILE="${UNPACK_DIR}/${VERSION}/gcc_64/bin/qmake" sed -i "s|\/home\/qt\/work\/install\/bin\/qmake|$QMAKE_FILE|g" "${ANDROID_QMAKE_FILE}" + sed -i "s|\/Users\/qt\/work\/install\/bin\/qmake|$QMAKE_FILE|g" "${ANDROID_QMAKE_FILE}" + elif [ "${TARGET_PLATFORM}" == "ios" ] && [ ! "${VERSION}" \< "6.0.0" ]; then + CONF_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/target_qt.conf" + sed -i.bak "s|HostData=target|HostData=../$TOOLCHAIN|g" "${CONF_FILE}" + sed -i.bak "s|HostPrefix=..\/..\/|HostPrefix=..\/..\/macos|g" "${CONF_FILE}" + IOS_QMAKE_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/qmake" + QMAKE_FILE="${UNPACK_DIR}/${VERSION}/macos/bin/qmake" + sed -i.bak "s|\/Users\/qt\/work\/install\/bin\/qmake|${QMAKE_FILE}|g" "${IOS_QMAKE_FILE}" else CONF_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/qt.conf" echo "[Paths]" > ${CONF_FILE} From 70c0f63d9b509417bf9ba84e4ad1802d32a0515d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Fri, 26 Apr 2024 17:53:11 +0200 Subject: [PATCH 11/15] Scripting: Fixed crash after using tiled.project Crash caused by a double-deletion of the EditableProject, since both the Project as well as the ProjectDocument classes were deleting it from their destructors (in the Object and Document superclasses, respectively). This issue was introduced in 4244060c3fcb29ed514de5f419eb165a6cdbfb4f. --- src/tiled/projectdocument.cpp | 7 +++++++ src/tiled/projectdocument.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/tiled/projectdocument.cpp b/src/tiled/projectdocument.cpp index 26849d85f4..32b3c197a5 100644 --- a/src/tiled/projectdocument.cpp +++ b/src/tiled/projectdocument.cpp @@ -37,6 +37,13 @@ ProjectDocument::ProjectDocument(std::unique_ptr project, QObject *pare this, [this] { mProject->save(); }); } +ProjectDocument::~ProjectDocument() +{ + // The Editable needs to be deleted before the Project, otherwise ~Object() + // will delete it, whereas the editable is actually owned by the Document. + mEditable.reset(); +} + QString ProjectDocument::displayName() const { return mProject->fileName(); diff --git a/src/tiled/projectdocument.h b/src/tiled/projectdocument.h index 310bd83c22..76e39c0459 100644 --- a/src/tiled/projectdocument.h +++ b/src/tiled/projectdocument.h @@ -32,6 +32,7 @@ class ProjectDocument : public Document public: ProjectDocument(std::unique_ptr project, QObject *parent = nullptr); + ~ProjectDocument() override; QString displayName() const override; FileFormat *writerFormat() const override; From 19c2b8d153e3dfc409b631260237b69dfccf5a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 30 Apr 2024 12:06:27 +0200 Subject: [PATCH 12/15] Added element to AppStream metadata This is now required for publishing the Flatpak. --- org.mapeditor.Tiled.appdata.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org.mapeditor.Tiled.appdata.xml b/org.mapeditor.Tiled.appdata.xml index d5dad010c5..016fab3fd8 100644 --- a/org.mapeditor.Tiled.appdata.xml +++ b/org.mapeditor.Tiled.appdata.xml @@ -6,6 +6,9 @@ Tiled General purpose map editor Leveleditor für allgemeine Zwecke + + Thorbjørn Lindeijer + 2D mapeditor From 15e7486e1540b87b870839ed55b44cca35d0eaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 1 May 2024 16:19:55 +0200 Subject: [PATCH 13/15] Fixed Qt version check for groupbox frame rendering The change to Qt was cherry-picked to Qt 6.6.3. This further amends 93f6fef14052e6797440e3f4c4a093f7507b2249. --- src/tiled/tiledproxystyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tiled/tiledproxystyle.cpp b/src/tiled/tiledproxystyle.cpp index 0ba0f41ce0..476bde79b2 100644 --- a/src/tiled/tiledproxystyle.cpp +++ b/src/tiled/tiledproxystyle.cpp @@ -27,7 +27,7 @@ #include #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 6, 3) #include #endif #include @@ -357,7 +357,7 @@ void TiledProxyStyle::drawPrimitive(PrimitiveElement element, case PE_FrameGroupBox: { int topMargin = 3; -#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 6, 3) auto control = qobject_cast(widget); if (control && !control->isCheckable() && control->title().isEmpty()) { // Shrinking the topMargin if Not checkable AND title is empty From f88ee28d622ca383db5e6f3d856343533eb2c4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 2 May 2024 17:28:25 +0200 Subject: [PATCH 14/15] Python plugin: Raised minimum Python version to 3.8 Fixed deprecation warnings by replacing `Py_NoSiteFlag` and `Py_NoUserSiteDirectory` variables with their `PyConfig` equivalent, supported since Python 3.8. --- NEWS.md | 1 + qbs/imports/PythonProbe.qbs | 7 +++---- src/plugins/python/python.qbs | 17 +++-------------- src/plugins/python/pythonplugin.cpp | 18 ++++++++++++++---- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/NEWS.md b/NEWS.md index 83dddd0e88..0e3a758ba5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,6 +16,7 @@ * Godot 4 plugin: Use Godot 4.2 tile transformation flags (by Rick Yorgason, #3895) * Godot 4 plugin: Fixed positioning of tile collision shapes (by Ryan Petrie, #3862) * GameMaker 2 plugin: Fixed positioning of objects on isometric maps +* Python plugin: Raised minimum Python version to 3.8 * tmxrasterizer: Added --hide-object and --show-object arguments (by Lars Luz, #3819) * tmxrasterizer: Added --frames and --frame-duration arguments to export animated maps as multiple images (#3868) * tmxrasterizer: Fixed --hide/show-layer to work on group layers (#3899) diff --git a/qbs/imports/PythonProbe.qbs b/qbs/imports/PythonProbe.qbs index e0a649ec5b..52eae7fc32 100644 --- a/qbs/imports/PythonProbe.qbs +++ b/qbs/imports/PythonProbe.qbs @@ -7,10 +7,9 @@ import qbs.Utilities Probe { id: pythonDllProbe - condition: qbs.targetOS.contains("windows") - property string pythonDir: pythonInstallDir // Input property string buildVariant: qbs.buildVariant // Input + property string minVersion: "3.5" // Input property string fileNamePrefix // Output configure: { @@ -45,9 +44,9 @@ Probe { + output + "'"); return; } - if (Utilities.versionCompare(versionNumberString, "3.5") < 0) { + if (Utilities.versionCompare(versionNumberString, minVersion) < 0) { printWarning("The Python installation at '" + pythonDir - + "' has version " + versionNumberString + ", but 3.5 or higher " + + "' has version " + versionNumberString + ", but " + minVersion + " or higher " + "is required."); return; } diff --git a/src/plugins/python/python.qbs b/src/plugins/python/python.qbs index f8b70c0b9b..99d23411b0 100644 --- a/src/plugins/python/python.qbs +++ b/src/plugins/python/python.qbs @@ -10,7 +10,7 @@ TiledPlugin { if (qbs.targetOS.contains("windows")) return pythonDllProbe.found; - return pkgConfigPython3Embed.found || pkgConfigPython3.found; + return pkgConfigPython3.found; } cpp.cxxFlags: { @@ -22,25 +22,14 @@ TiledPlugin { Probes.PkgConfigProbe { id: pkgConfigPython3 - name: "python3" - } - - Probes.PkgConfigProbe { - id: pkgConfigPython3Embed name: "python3-embed" + minVersion: "3.8" } PythonProbe { id: pythonDllProbe pythonDir: Environment.getEnv("PYTHONHOME") - } - - Properties { - condition: pkgConfigPython3Embed.found - cpp.cxxFlags: outer.concat(pkgConfigPython3Embed.cflags) - cpp.dynamicLibraries: pkgConfigPython3Embed.libraries - cpp.libraryPaths: pkgConfigPython3Embed.libraryPaths - cpp.linkerFlags: pkgConfigPython3Embed.linkerFlags + minVersion: "3.8" } Properties { diff --git a/src/plugins/python/pythonplugin.cpp b/src/plugins/python/pythonplugin.cpp index 2148681638..363fd7ca14 100644 --- a/src/plugins/python/pythonplugin.cpp +++ b/src/plugins/python/pythonplugin.cpp @@ -76,14 +76,24 @@ PythonPlugin::~PythonPlugin() void PythonPlugin::initialize() { if (!Py_IsInitialized()) { - // PEP370 - Py_NoSiteFlag = 1; - Py_NoUserSiteDirectory = 1; + // PEP 587 + PyConfig config; + PyConfig_InitPythonConfig(&config); + + // PEP 370 + config.site_import = 0; + config.user_site_directory = 0; PyImport_AppendInittab("tiled", PyInit_tiled); PyImport_AppendInittab("tiled.qt", PyInit_tiled); PyImport_AppendInittab("tiled.Tiled", PyInit_tiled); - Py_Initialize(); + + PyStatus status = Py_InitializeFromConfig(&config); + if (PyStatus_Exception(status)) { + Tiled::ERROR("Python initialization failed"); + handleError(); + return; + } PyObject *pmod = PyImport_ImportModule("tiled"); From 288cd98b653a477ce306dd3c0b0a1e7262f6fad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 2 May 2024 20:32:51 +0200 Subject: [PATCH 15/15] Python plugin: Added forgotten PyConfig_Clear call --- src/plugins/python/pythonplugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/python/pythonplugin.cpp b/src/plugins/python/pythonplugin.cpp index 363fd7ca14..de137f7c0f 100644 --- a/src/plugins/python/pythonplugin.cpp +++ b/src/plugins/python/pythonplugin.cpp @@ -89,6 +89,8 @@ void PythonPlugin::initialize() PyImport_AppendInittab("tiled.Tiled", PyInit_tiled); PyStatus status = Py_InitializeFromConfig(&config); + PyConfig_Clear(&config); + if (PyStatus_Exception(status)) { Tiled::ERROR("Python initialization failed"); handleError();