From 196f17cfa4b53742f3f5c665a50e6d03639493f4 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 28 Nov 2024 21:01:46 +0100 Subject: [PATCH 01/16] CMakePM: Show user defined (custom) utility targets in cmo locator Amends 13efeb4c23717e37a14c3074249dc555dc177081 We don't want to show something like `_lupdate` since it's part of Qt and not relevant to the users. Fixes: QTCREATORBUG-32080 Change-Id: If8789db5aa308c3e6c4ba03c7c04c7bccc15feea Reviewed-by: Eike Ziller --- .../cmakeprojectmanager/cmakelocatorfilter.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp index c3712e06979..72831a4c37e 100644 --- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp @@ -65,19 +65,24 @@ static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor) return AcceptResult(); }; } - bool realTarget = false; - if (!target.backtrace.isEmpty() && target.targetType != UtilityType) { + // We want to show real targets (executables, libraries) and also + // custom targets defined in the project via add_custom_target. + bool targetOfInterest = false; + if (!target.backtrace.isEmpty()) { const FilePath path = target.backtrace.last().path; const int line = target.backtrace.last().line; entry.linkForEditor = {path, line}; entry.extraInfo = path.shortNativePath(); - realTarget = true; + + if (target.targetType != UtilityType || path == projectPath + || path.isChildOf(projectPath)) + targetOfInterest = true; } else { entry.extraInfo = projectPath.shortNativePath(); } entry.highlightInfo = ILocatorFilter::highlightInfo(match); entry.filePath = cmakeProject->projectFilePath(); - if (acceptor || realTarget) { + if (acceptor || targetOfInterest) { if (match.capturedStart() == 0) entries[int(ILocatorFilter::MatchLevel::Best)].append(entry); else if (match.lastCapturedIndex() == 1) From 98548ee384d1ce9bc208ae89e7e86ae9ed58df49 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 5 Dec 2024 16:32:43 +0100 Subject: [PATCH 02/16] QtC plugin wizard: Improve downloading Qt further Utilize the information from the downloaded Updates.xml more. - Separate the package sections for "parsing", throw away "debug" ones and limit to the right compiler spec - When downloading a module, find the right package section, and construct the URL via the Name and DownloadableArchives information This way we no longer depend on hardcoded archive postfixes and hardcoded archive URL structures. Task-number: QTCREATORBUG-31184 Change-Id: I98912677f1618fe281cf2b8aaf989c5c6e0f3c51 Reviewed-by: Cristian Adam --- .../github_workflows_build_cmake.yml | 72 +++++++++---------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml index 84a5a24c76a..820b399c113 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml @@ -87,69 +87,65 @@ jobs: string(REPLACE "." "" qt_version_dotless "${qt_version}") if ("${{ runner.os }}" STREQUAL "Windows") set(url_os "windows_x86") - set(qt_package_arch_suffix "win64_msvc2022_64") - set(qt_dir_prefix "${qt_version}/msvc_64") - set(qt_package_suffix "-Windows-Windows_11_23H2-MSVC2022-Windows-Windows_11_23H2-X86_64") + set(compiler_id "win64_msvc2022_64") elseif ("${{ runner.os }}" STREQUAL "Linux") set(url_os "linux_x64") - set(qt_package_arch_suffix "linux_gcc_64") - set(qt_dir_prefix "${qt_version}/gcc_64") - set(qt_package_suffix "-Linux-RHEL_8_10-GCC-Linux-RHEL_8_10-X86_64") + set(compiler_id "linux_gcc_64") elseif ("${{ runner.os }}" STREQUAL "macOS") set(url_os "mac_x64") - set(qt_package_arch_suffix "clang_64") - set(qt_dir_prefix "${qt_version}/macos") - set(qt_package_suffix "-MacOS-MacOS_14-Clang-MacOS-MacOS_14-X86_64-ARM64") + set(compiler_id "clang_64") endif() set(qt_base_url "https://download.qt.io/online/qtsdkrepository/${url_os}/desktop/qt6_${qt_version_dotless}/qt6_${qt_version_dotless}") file(DOWNLOAD "${qt_base_url}/Updates.xml" ./Updates.xml SHOW_PROGRESS) file(READ ./Updates.xml updates_xml) - string(REGEX MATCH "qt.qt6.*([0-9+-.]+)" updates_xml_output "${updates_xml}") - set(qt_package_version ${CMAKE_MATCH_1}) + # get the package sections, only for given compiler, without the "debug info" ones + string(REGEX REPLACE "" ";" sections "${updates_xml}") + list(FILTER sections EXCLUDE REGEX ".*debug.*") + list(FILTER sections INCLUDE REGEX ".*${compiler_id}.*") # Save the path for other steps - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qt6/${qt_dir_prefix}" qt_dir) + file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/qt/" qt_dir) file(APPEND "$ENV{GITHUB_OUTPUT}" "qt_dir=${qt_dir}") + function(get_sub_url outvar module) + set(filtered ${sections}) + list(FILTER filtered INCLUDE REGEX ".*${module}.*") + list(LENGTH filtered count) + if (count LESS 1) + set(${outvar} "" PARENT_SCOPE) + return() + endif() + list(GET filtered 0 section) + string(REGEX MATCH "(.*)" match "${section}") + set(name ${CMAKE_MATCH_1}) + string(REGEX MATCH "(.*)" match "${section}") + set(version ${CMAKE_MATCH_1}) + string(REGEX MATCH ".*(${module}[^,]+).*" match "${section}") + set(archive ${CMAKE_MATCH_1}) + set(${outvar} "${name}/${version}${archive}" PARENT_SCOPE) + endfunction() + message("Downloading Qt to ${qt_dir}") - function(downloadAndExtract url archive subdir) + function(downloadAndExtract module subdir) file(MAKE_DIRECTORY "${qt_dir}/${subdir}") - message("Downloading ${url}") + set(archive "${module}.7z") + get_sub_url(sub_url ${module}) + set(url "${qt_base_url}/${sub_url}") + message("Downloading ${module} from ${url}") message("... extracting to ${qt_dir}/${subdir}") file(DOWNLOAD "${url}" "$ENV{GITHUB_WORKSPACE}/${archive}" SHOW_PROGRESS) execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf "$ENV{GITHUB_WORKSPACE}/${archive}" WORKING_DIRECTORY "${qt_dir}/${subdir}") endfunction() - foreach(package qtbase qtdeclarative) - downloadAndExtract( - "${qt_base_url}/qt.qt6.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}.7z" - ${package}.7z - "" - ) - endforeach() - - foreach(package qt5compat qtshadertools) - downloadAndExtract( - "${qt_base_url}/qt.qt6.${qt_version_dotless}.addons.${package}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}.7z" - ${package}.7z - "" - ) + foreach(package qtbase qtdeclarative qt5compat qtshadertools) + downloadAndExtract(${package} "") endforeach() # uic depends on libicu*.so if ("${{ runner.os }}" STREQUAL "Linux") - if (qt_version VERSION_LESS "6.7.0") - set(uic_suffix "Rhel7.2-x64") - else() - set(uic_suffix "Rhel8.6-x86_64") - endif() - downloadAndExtract( - "${qt_base_url}/qt.qt6.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}icu-linux-${uic_suffix}.7z" - icu.7z - "lib" - ) + downloadAndExtract("icu" "lib") endif() execute_process(COMMAND ${qt_dir}/bin/qmake -query) From 976b539f57f96302bb55e7a733acb8256804c869 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 13 Nov 2024 13:59:04 +0100 Subject: [PATCH 03/16] German translation: TextEditor, Utils, Vcs, WebAssembly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0692c6772bdc2a2ed1257b169591261414481b07 Reviewed-by: Robert Löhning --- share/qtcreator/translations/qtcreator_de.ts | 62 ++++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/share/qtcreator/translations/qtcreator_de.ts b/share/qtcreator/translations/qtcreator_de.ts index c4312a7d412..d84cc17aa7c 100644 --- a/share/qtcreator/translations/qtcreator_de.ts +++ b/share/qtcreator/translations/qtcreator_de.ts @@ -53663,19 +53663,19 @@ Die Datei "%1" konnte nicht geöffnet werden. Ctrl+Alt+. - + Ctrl+Alt+. Ctrl+Alt+, - + Ctrl+Alt+, Sort by Filenames - + Nach Dateiname sortieren Ctrl+Alt+P - + Ctrl+Alt+P Alt+Meta+M @@ -54910,19 +54910,19 @@ Bestimmt das Verhalten bezüglich der Einrückung von Fortsetzungszeilen. Fold Recursively - + Rekursiv einklappen Fold All - + Alle einklappen Unfold Recursively - + Rekursiv aufklappen Unfold All - + Alle aufklappen Zoom: %1% @@ -56062,11 +56062,11 @@ Um den Stil von benutzerdefinierten Operatoren festzulegen, verwenden Sie " Attribute - + Attribut Attributes. - + Attribute. Comment @@ -56545,7 +56545,7 @@ Außer Leerzeichen innerhalb von Kommentaren und Zeichenketten. Copy Hash to Clipboard - + Hash in die Zwischenablage kopieren <b>Note:</b> "%1" or "%2" is enabled in the instant blame settings. @@ -56598,23 +56598,23 @@ Außer Leerzeichen innerhalb von Kommentaren und Zeichenketten. Select Previous Suggestion - + Vorangehenden Vorschlag auswählen Select Next Suggestion - + Nächsten Vorschlag auswählen Apply (%1) - Anwenden (%1) + Anwenden (%1) Apply Word (%1) - Wort anwenden (%1) + Wort anwenden (%1) Apply Line - + Zeile anwenden @@ -57107,11 +57107,11 @@ Die Trace-Daten sind verloren. Add to project: - + Zu Projekt hinzufügen: Chosen project wizard does not support the build system. - + Das Buildsystem wird vom gewählten Assistenten nicht unterstützt. Directory "%1" will be created. @@ -57368,7 +57368,7 @@ Die Trace-Daten sind verloren. renameFile is not implemented for "%1". - + renameFile ist für "%1" nicht implementiert. fileContents is not implemented for "%1". @@ -57388,11 +57388,11 @@ Die Trace-Daten sind verloren. Failed to watch "%1". - + Watch für "%1" ist fehlgeschlagen. Failed to watch "%1", it does not exist. - + Watch für "%1" ist fehlgeschlagen, es existiert nicht. Refusing to remove the standard directory "%1". @@ -57416,7 +57416,7 @@ Die Trace-Daten sind verloren. Failed to rename file "%1" to "%2": %3 - + Die Datei "%1" konnte nicht in "%2" umbenannt werden: %3 File "%1" does not exist. @@ -57448,7 +57448,7 @@ Die Trace-Daten sind verloren. removeFile is not implemented for "%1". - + removeFile ist für "%1" nicht implementiert. Cannot copy "%1" to "%2": %3 @@ -57531,7 +57531,7 @@ Die Trace-Daten sind verloren. Failed to set up scratch buffer in "%1". - + Notizbereich in "%1" konnte nicht erzeugt werden. %1 on %2 @@ -57557,7 +57557,7 @@ Die Trace-Daten sind verloren. Failed to move %1 to %2. Removing the source file failed: %3 - + Das Verschieben von %1 nach %2 ist fehlgeschlagen. Das Entfernen der Quelldatei ist fehlgeschlagen: %3 No "localSource" device hook set. @@ -57724,7 +57724,7 @@ Die Trace-Daten sind verloren. Failed to expand macros in process arguments: %1 - + Das Expandieren von Makros in Prozessargumenten ist fehlgeschlagen: %1 %1: Full path including file name. @@ -59562,7 +59562,7 @@ Check settings or ensure Valgrind is installed and available in PATH. Cannot commit: %1 - + Commit fehlgeschlagen: %1 %1 %2/%n File(s) @@ -59922,19 +59922,19 @@ should a repository require SSH-authentication (see documentation on SSH and the The chosen directory is an emsdk location. - + Das gewählte Verzeichnis ist der Ort eines emsdk. An SDK is installed. - + Ein SDK ist installiert. An SDK is activated. - + Ein SDK ist aktiviert. The activated SDK is usable by %1. - + Das aktivierte SDK ist von %1 benutzbar. The activated version %1 is not supported by %2. Activate version %3 or higher. From 0958fedbdf48a1090255a3dee2771d43347e5fcf Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 4 Dec 2024 14:19:48 +0100 Subject: [PATCH 04/16] ClangTools: Create compilation db also for DocumentClangToolRunner This was forgotten in a360d855ae60f4686fa0d2ef7595f4f951fca581. Fixes: QTCREATORBUG-32098 Change-Id: Iea3b3b61238164d8fb5190131567af2e21a7b7d4 Reviewed-by: David Schulz --- src/plugins/clangtools/documentclangtoolrunner.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/clangtools/documentclangtoolrunner.cpp b/src/plugins/clangtools/documentclangtoolrunner.cpp index df9109ce128..093df0ab7b0 100644 --- a/src/plugins/clangtools/documentclangtoolrunner.cpp +++ b/src/plugins/clangtools/documentclangtoolrunner.cpp @@ -3,6 +3,7 @@ #include "documentclangtoolrunner.h" +#include "clangtoolscompilationdb.h" #include "clangtoolsconstants.h" #include "clangtoolrunner.h" #include "clangtoolsutils.h" @@ -158,6 +159,18 @@ static Environment projectBuildEnvironment(Project *project) void DocumentClangToolRunner::run() { + for (const ClangToolType type : {ClangToolType::Tidy, ClangToolType::Clazy}) { + ClangToolsCompilationDb &db = ClangToolsCompilationDb::getDb(type); + db.disconnect(this); + if (db.generateIfNecessary()) { + connect(&db, &ClangToolsCompilationDb::generated, this, [this](bool success) { + if (success) + run(); + }, Qt::SingleShotConnection); + return; + } + } + if (m_projectSettingsUpdate) disconnect(m_projectSettingsUpdate); m_taskTreeRunner.reset(); From 99690460938d131443680b910780920f7b075b8f Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 5 Dec 2024 12:46:17 +0100 Subject: [PATCH 05/16] CppEditor: Fix pretty-printing of auto type Task-number: QTCREATORBUG-31678 Change-Id: I2c1684c71315d50c98f451b280fbfd08b5d8d3e8 Reviewed-by: Christian Stenger --- src/libs/cplusplus/TypePrettyPrinter.cpp | 3 +++ .../cppeditor/quickfixes/insertfunctiondefinition.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index 0e7ba193427..5b617054fd4 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -116,6 +116,9 @@ void TypePrettyPrinter::visit(UndefinedType *) _text.prepend(QLatin1String("signed")); else if (_fullySpecifiedType.isUnsigned()) _text.prepend(QLatin1String("unsigned")); + } else if (_fullySpecifiedType.isAuto()) { + prependSpaceUnlessBracket(); + _text.prepend("auto"); } prependCv(_fullySpecifiedType); diff --git a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp index 0f9f8461380..f8ff21cd6ad 100644 --- a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp +++ b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp @@ -1883,17 +1883,17 @@ foo::foo2::MyType foo::foo2::bar() QByteArray original = "class Foo\n" "{\n" - " template\n" + " template\n" " void fun@c();\n" "};\n"; QByteArray expected = "class Foo\n" "{\n" - " template\n" + " template\n" " void fun@c();\n" "};\n" "\n" - "template\n" + "template\n" "inline void Foo::func()\n" "{\n" "\n" From 0f2b0e7aa2107eca54ea32fe64e9008218427277 Mon Sep 17 00:00:00 2001 From: Krzysztof Chrusciel Date: Fri, 6 Dec 2024 13:20:04 +0100 Subject: [PATCH 06/16] Lua: Expose setText and setIconPath for PushButton Change-Id: I15de1b4330a0f8b948bf3b2c4666cccf5222ddfa Reviewed-by: Marcus Tillmanns --- src/plugins/lua/bindings/gui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/lua/bindings/gui.cpp b/src/plugins/lua/bindings/gui.cpp index aae28b7ddcf..17f6016c7ae 100644 --- a/src/plugins/lua/bindings/gui.cpp +++ b/src/plugins/lua/bindings/gui.cpp @@ -514,6 +514,10 @@ void setupGuiModule() sol::factories([guard](const sol::table &children) { return constructWidgetType(children, guard); }), + "setText", + &PushButton::setText, + "setIconPath", + &PushButton::setIconPath, sol::base_classes, sol::bases()); From 79e4cf33e88e2118b3d6158ab6d3c047a744646e Mon Sep 17 00:00:00 2001 From: Liu Zhangjian Date: Thu, 5 Dec 2024 20:08:53 +0800 Subject: [PATCH 07/16] fix: [gcctoolchain] Fix GCC compiler version detection issue Fixed incorrect position check for compiler version detection in `findCompilerCandidates` function. Changed from `pos + 2` to `pos + 1` to properly detect compiler names with single digit versions like gcc-8 and clang-7. Change-Id: I6eb16c6c88a8944ee67af42ea4c9fb244cbdb7e8 Reviewed-by: Christian Kandeler Reviewed-by: Orgad Shaneh --- src/plugins/projectexplorer/gcctoolchain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 7dbae83b62f..6c35a127efb 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -1406,6 +1406,7 @@ static FilePaths findCompilerCandidates(OsType os, if (os == OsTypeWindows && fileName.endsWith(u".exe", Qt::CaseInsensitive)) fileName.chop(4); + // Do not `continue`, proceed to detect further variants if (fileName == compilerName) compilerPaths << executable; @@ -1426,7 +1427,7 @@ static FilePaths findCompilerCandidates(OsType os, // if not at the end, it must by followed by a hyphen and a digit between 1 and 9 pos += cl; if (pos != fileName.size()) { - if (pos + 2 >= fileName.size()) + if (pos + 1 >= fileName.size()) continue; if (fileName.at(pos) != '-') continue; From a29c17e2c3a824241d87f7a115c3fec28a1da908 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Fri, 6 Dec 2024 11:40:48 +0100 Subject: [PATCH 08/16] Wizards: Bump install-dev-package to v1.6 We were having issues with the download of the Qt Creator packages failing. The new version of the install-dev-package script has more error output that might help with tracking down the issue as it is intermittent. Change-Id: I677bbf893215a056bea96feecef9bcd241cf85d6 Reviewed-by: Eike Ziller --- .../wizards/qtcreatorplugin/github_workflows_build_cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml index 820b399c113..eb86ce41b10 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml @@ -150,7 +150,7 @@ jobs: execute_process(COMMAND ${qt_dir}/bin/qmake -query) - name: Download Qt Creator - uses: qt-creator/install-dev-package@v1.2 + uses: qt-creator/install-dev-package@v1.6 with: version: ${{ env.QT_CREATOR_VERSION }} unzip-to: 'qtcreator' From dc5362535935d443729a49e92de0469c8e60ee5d Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 9 Dec 2024 09:22:38 +0100 Subject: [PATCH 09/16] Debugger: Fix "{En,Dis}able All Breakpoints" context menu action The actual set of breakpoints to which the option was applied could have been different than the one used at the time of the creation of the context menu due to background activity. Found by crash reporter. Change-Id: I43a75c8659fe8a11988fa081022965db4ce9233c Reviewed-by: Eike Ziller --- src/plugins/debugger/breakhandler.cpp | 46 ++++++++++++--------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 5d0b25a3729..2636e99b256 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -1668,35 +1668,31 @@ bool BreakHandler::contextMenuEvent(const ItemViewEvent &ev) } ); - QList enabledBreakpoints; - QList disabledBreakpoints; - forItemsAtLevel<1>([&enabledBreakpoints, &disabledBreakpoints](Breakpoint bp) { - if (bp) { - if (bp->isEnabled()) - enabledBreakpoints.append(bp); - else - disabledBreakpoints.append(bp); - } + bool canDisableAll = false; + bool canEnableAll = false; + forItemsAtLevel<1>([&canDisableAll, &canEnableAll](Breakpoint bp) { + if (bp) + (bp->isEnabled() ? canDisableAll : canEnableAll) = true; }); - addAction(this, menu, Tr::tr("Disable All Breakpoints"), - !enabledBreakpoints.isEmpty(), - [this, enabledBreakpoints] { - for (Breakpoint bp : enabledBreakpoints) { - if (GlobalBreakpoint gbp = bp->globalBreakpoint()) - gbp->setEnabled(false, false); - requestBreakpointEnabling(bp, false); - } + addAction(this, menu, Tr::tr("Disable All Breakpoints"), canDisableAll, [this] { + forItemsAtLevel<1>([this](Breakpoint bp) { + if (bp && bp->isEnabled()) { + if (GlobalBreakpoint gbp = bp->globalBreakpoint()) + gbp->setEnabled(false, false); + requestBreakpointEnabling(bp, false); + } + }); }); - addAction(this, menu, Tr::tr("Enable All Breakpoints"), - !disabledBreakpoints.isEmpty(), - [this, disabledBreakpoints] { - for (Breakpoint bp : disabledBreakpoints) { - if (GlobalBreakpoint gbp = bp->globalBreakpoint()) - gbp->setEnabled(true, false); - requestBreakpointEnabling(bp, true); - } + addAction(this, menu, Tr::tr("Enable All Breakpoints"), canEnableAll, [this] { + forItemsAtLevel<1>([this](Breakpoint bp) { + if (bp && !bp->isEnabled()) { + if (GlobalBreakpoint gbp = bp->globalBreakpoint()) + gbp->setEnabled(true, false); + requestBreakpointEnabling(bp, true); + } + }); }); addAction(this, menu, From 404832815a60ad8c5fce04f71812345ea77d22f3 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 6 Dec 2024 15:33:47 +0100 Subject: [PATCH 10/16] CppEditor: Fix "inline" placement also when moving definitions Not just when creating them. Amends 9c4ba3ff21fc4691adb0017cd9ec92c567ba7bf8. Task-number: QTCREATORBUG-31678 Change-Id: If1dbb1d5e247543fa91d3c086622926f5daeca93 Reviewed-by: Christian Stenger --- .../cppeditor/quickfixes/cppquickfix_test.cpp | 6 ++--- .../cppeditor/quickfixes/cppquickfix_test.h | 4 ++-- .../quickfixes/movefunctiondefinition.cpp | 24 +++++++++++++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/plugins/cppeditor/quickfixes/cppquickfix_test.cpp b/src/plugins/cppeditor/quickfixes/cppquickfix_test.cpp index f487764101b..8107ce0baf4 100644 --- a/src/plugins/cppeditor/quickfixes/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/quickfixes/cppquickfix_test.cpp @@ -35,10 +35,10 @@ namespace CppEditor { namespace Internal { namespace Tests { -QList singleDocument(const QByteArray &original, - const QByteArray &expected) +QList singleDocument( + const QByteArray &original, const QByteArray &expected, const QByteArray fileName) { - return {CppTestDocument::create("file.cpp", original, expected)}; + return {CppTestDocument::create(fileName, original, expected)}; } BaseQuickFixTestCase::BaseQuickFixTestCase(const QList &testDocuments, diff --git a/src/plugins/cppeditor/quickfixes/cppquickfix_test.h b/src/plugins/cppeditor/quickfixes/cppquickfix_test.h index b1990629706..b6d3030ef31 100644 --- a/src/plugins/cppeditor/quickfixes/cppquickfix_test.h +++ b/src/plugins/cppeditor/quickfixes/cppquickfix_test.h @@ -86,8 +86,8 @@ public: int operationIndex = 0); }; -QList singleDocument(const QByteArray &original, - const QByteArray &expected); +QList singleDocument( + const QByteArray &original, const QByteArray &expected, const QByteArray fileName = "file.cpp"); } // namespace Tests } // namespace Internal diff --git a/src/plugins/cppeditor/quickfixes/movefunctiondefinition.cpp b/src/plugins/cppeditor/quickfixes/movefunctiondefinition.cpp index ef970f952fa..8a1429aeba9 100644 --- a/src/plugins/cppeditor/quickfixes/movefunctiondefinition.cpp +++ b/src/plugins/cppeditor/quickfixes/movefunctiondefinition.cpp @@ -107,9 +107,23 @@ public: Scope *scopeAtInsertPos = m_toFile->cppDocument()->scopeAt(l.line(), l.column()); // construct definition - const QString funcDec = inlinePrefix(m_toFile->filePath(), [this] { return m_type == MoveOutside; }) - + definitionSignature(m_operation, funcAST, m_fromFile, m_toFile, - scopeAtInsertPos); + const QString inlinePref = inlinePrefix(m_toFile->filePath(), [this] { + return m_type == MoveOutside; + }); + QString funcDec = definitionSignature(m_operation, funcAST, m_fromFile, m_toFile, + scopeAtInsertPos); + QString input = funcDec; + int inlineIndex = 0; + const QRegularExpression templateRegex("template\\s*<[^>]*>"); + while (input.startsWith("template")) { + const QRegularExpressionMatch match = templateRegex.match(input); + if (match.hasMatch()) { + inlineIndex += match.captured().size() + 1; + input = input.mid(match.captured().size() + 1); + } + } + funcDec.insert(inlineIndex, inlinePref); + QString funcDef = prefix + funcDec; const int startPosition = m_fromFile->endOf(funcAST->declarator); const int endPosition = m_fromFile->endOf(funcAST); @@ -1182,11 +1196,11 @@ private slots: "class Foo { void fu@nc(); };\n" "\n" "template\n" - "void Foo::func() {}\n"; + "inline void Foo::func() {}\n"; ; MoveFuncDefOutside factory; - QuickFixOperationTest(singleDocument(original, expected), &factory); + QuickFixOperationTest(singleDocument(original, expected, "file.h"), &factory); } void testMemberFunctionTemplate() From 1a781f9295c89bd32400ccd0d8b25960225d071c Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Mon, 9 Dec 2024 11:26:11 +0100 Subject: [PATCH 11/16] CMakePM: Use qobject_cast instead of static_cast for CMakeProject Attempt at fixing sentry issue QT-CREATOR-6R Change-Id: Ia19ec8b0507331e8531d7ffec2c86f203ecae0db Reviewed-by: Marcus Tillmanns --- src/plugins/cmakeprojectmanager/projecttreehelper.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/projecttreehelper.cpp b/src/plugins/cmakeprojectmanager/projecttreehelper.cpp index a97050541d5..daa1de53041 100644 --- a/src/plugins/cmakeprojectmanager/projecttreehelper.cpp +++ b/src/plugins/cmakeprojectmanager/projecttreehelper.cpp @@ -125,11 +125,12 @@ void addCMakePresets(FolderNode *root, const Utils::FilePath &sourceDir) presetFileNames << "CMakePresets.json"; presetFileNames << "CMakeUserPresets.json"; - const CMakeProject *cp = static_cast( + const auto cmakeProject = qobject_cast( ProjectManager::projectForFile(sourceDir.pathAppended(Constants::CMAKE_LISTS_TXT))); + QTC_ASSERT(cmakeProject, return); - if (cp && cp->presetsData().include) - presetFileNames.append(cp->presetsData().include.value()); + if (cmakeProject->presetsData().include) + presetFileNames.append(cmakeProject->presetsData().include.value()); std::vector> presets; for (const auto &fileName : presetFileNames) { From f6d57999d80c04f930916197806e3cd47b88d81c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 9 Dec 2024 14:40:04 +0100 Subject: [PATCH 12/16] OpenEditorsWindow: Fix crash when entries are removed behind the back of the window. The open editors window (that appears on ctrl+tab / opt+tab) keeps pointers to Entry items from the DocumentModel. Usually that is no problem, because the editor manager hides the open editors window before closing editors. But there was an issue with suspended entries, that can be reproduced with some effort, e.g. - Give e.g. "Unload/Close Project" a shortcut that you can trigger while the popup is open, like Opt+K on macOS, or Ctrl+Shift+J on Lin/Win - Open a project and a few files from the project - Switch the document switcher of the editor view to "" - Close & reopen QtC, reload the session - You should now have a few "suspended" documents, and *only* suspended documents, since the editor view doesn't show anything - Open the open editors window with ctrl+tab / opt+tab and trigger the "close project" shortcut without closing the popup - The documents and the project close, but the popup is open and shows the old items - The moment you press e.g. tab again to interact with the popup, it crashes Just close the popup if items are removed from the document model "behind its back". Also clear all items whenever it is set invisible so we don't have references to broken items hanging around. Change-Id: I70853838f292235efea0561755b35c20aaa8473d Reviewed-by: David Schulz --- src/plugins/coreplugin/editormanager/openeditorswindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 519d0ff954c..70dc13d2bd3 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -146,6 +146,11 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) auto layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_editorView); + + // Close the popup and clear it if documents are closed behind the back of the view + connect(DocumentModel::model(), &QAbstractItemModel::rowsAboutToBeRemoved, this, [this] { + setVisible(false); + }); } void OpenEditorsWindow::selectAndHide() @@ -159,6 +164,8 @@ void OpenEditorsWindow::setVisible(bool visible) QWidget::setVisible(visible); if (visible) setFocus(); + else + m_editorView->m_model.clear(); } bool OpenEditorsWindow::eventFilter(QObject *obj, QEvent *e) From 3b09ecbfa27948494f14ba0ace32e23919d793a1 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 4 Dec 2024 15:16:34 +0100 Subject: [PATCH 13/16] Editor: schedule rehighlight after font setting change That rehighlight vanished in the transition between highlighter -> async highlighterRunner -> highlight in batches Fixes: QTCREATORBUG-32116 Change-Id: I32ac8e3dd29b10399e0c7e5626faef02e037306f Reviewed-by: Christian Stenger --- src/plugins/texteditor/textdocument.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index 0f77c2568da..bdb6e7812b6 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -466,8 +466,10 @@ void TextDocument::applyFontSettings() block = block.next(); } updateLayout(); - if (d->m_highlighter) + if (d->m_highlighter) { d->m_highlighter->setFontSettings(d->m_fontSettings); + d->m_highlighter->scheduleRehighlight(); + } } const FontSettings &TextDocument::fontSettings() const From f2cb102c77aa65c57e199ad7acc1d36688660c53 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 10 Dec 2024 10:53:26 +0100 Subject: [PATCH 14/16] FakeVim: fix building tests with Qt 6.9 moc creates files using the identifier 'N' which breaks after #define N '\n' followed by #include "xxx.moc" later. Change-Id: I271b1f2aec737a75e5c2f8b2026056583d894b05 Reviewed-by: hjk --- src/plugins/fakevim/fakevim_test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/fakevim/fakevim_test.cpp b/src/plugins/fakevim/fakevim_test.cpp index ed98c8230af..49e8c2e0077 100644 --- a/src/plugins/fakevim/fakevim_test.cpp +++ b/src/plugins/fakevim/fakevim_test.cpp @@ -5058,5 +5058,7 @@ void FakeVimTester::test_vim_qtcreator() } // FakeVim::Internal -#include "fakevim_test.moc" +#undef N +#undef X +#include "fakevim_test.moc" From 7abf8ae477bf051624041bc851db4e90e8392c8d Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 10 Dec 2024 11:30:49 +0100 Subject: [PATCH 15/16] Fix compile with Qt 6.9 The QString::arg overload that accepts a base is explicitly disabled for everything that can be cast to a QAnyStringView, so for example T==char32_t or T==char16_t will is not usable in that overload. And the overload that accepts those types does not allow to set the base. Fix this by using T==int32_t or T==int16_t. Change-Id: Ib23a2ced7e03dab6de50458d36bc27689c6f8da9 Reviewed-by: hjk --- src/libs/utils/stringutils.cpp | 2 +- src/plugins/debugger/watchutils.cpp | 4 ++-- src/plugins/fakevim/fakevimhandler.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/utils/stringutils.cpp b/src/libs/utils/stringutils.cpp index e70a7fbb592..470c9961cdf 100644 --- a/src/libs/utils/stringutils.cpp +++ b/src/libs/utils/stringutils.cpp @@ -268,7 +268,7 @@ QString asciify(const QString &input) if (c.isPrint() && c.unicode() < 128) result.append(c); else - result.append(QString::fromLatin1("u%1").arg(c.unicode(), 4, 16, QChar('0'))); + result.append(QString::fromLatin1("u%1").arg(int16_t(c.unicode()), 4, 16, QChar('0'))); } return result; } diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 2e68578cf56..61406beebcc 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -254,8 +254,8 @@ QString escapeUnprintable(const QString &str, int unprintableBase) QString encoded; while (arrayView.size() >= 4) { - char32_t c; - memcpy(&c, arrayView.constData(), sizeof(char32_t)); + int32_t c; + memcpy(&c, arrayView.constData(), sizeof(int32_t)); if (QChar::isPrint(c)) encoded += toQString(arrayView.sliced(0, 4)); diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 29257505f21..2311e357b44 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -975,7 +975,7 @@ QString quoteUnprintable(const QString &ba) else if (cc == '\n') res += ""; else - res += QString("\\x%1").arg(c.unicode(), 2, 16, QLatin1Char('0')); + res += QString("\\x%1").arg(int16_t(c.unicode()), 2, 16, QLatin1Char('0')); } return res; } From 5cbe7d8819f21d7c427655736cba54fbeeef04a6 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 9 Dec 2024 12:27:25 +0100 Subject: [PATCH 16/16] ClangCodeModel: Fix potential crash when canceling indexing Change-Id: I9fe33f037fbb8b02a2890ec34c3a4f3584c4615e Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangdclient.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 8238ebf762e..29aa0b43e7b 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -21,17 +21,13 @@ #include #include #include -#include #include #include -#include #include #include #include #include #include -#include -#include #include #include #include @@ -45,16 +41,12 @@ #include #include #include -#include +#include #include #include #include #include #include -#include -#include -#include -#include #include #include #include @@ -62,9 +54,7 @@ #include #include #include -#include #include -#include #include #include @@ -462,8 +452,10 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir, c progressManager()->setTitleForToken( indexingToken(), project ? Tr::tr("Indexing %1 with clangd").arg(project->displayName()) : Tr::tr("Indexing session with clangd")); - progressManager()->setCancelHandlerForToken(indexingToken(), [this, project]() { - CppEditor::ClangdProjectSettings projectSettings(project); + progressManager()->setCancelHandlerForToken(indexingToken(), [this, p = QPointer(project)]() { + if (!p) + return; + CppEditor::ClangdProjectSettings projectSettings(p); projectSettings.blockIndexing(); progressManager()->endProgressReport(indexingToken()); });