From a0eff28c1cd67462882a026f510591779e70448d Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 7 Jan 2021 10:20:09 +0100 Subject: [PATCH 1/8] Utils: Fix crash in environment widget We called QTreeView::visualRect() with a potentially invalid model index, yielding a bogus QRect, from which we derived a bogus QPos, at which we tried to show a tooltip, which crashed Qt. While the whole logic around that code looks dubious, for now we just fix the crash by using a persistent model index. Fixes: QTCREATORBUG-25170 Change-Id: I5647d0ed04bd228bb2887ef06465212545b54f57 Reviewed-by: Christian Stenger --- src/libs/utils/namevaluevalidator.cpp | 2 ++ src/libs/utils/namevaluevalidator.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/namevaluevalidator.cpp b/src/libs/utils/namevaluevalidator.cpp index 580a476e01e..be4506b28df 100644 --- a/src/libs/utils/namevaluevalidator.cpp +++ b/src/libs/utils/namevaluevalidator.cpp @@ -62,6 +62,8 @@ void NameValueValidator::fixup(QString &input) const { Q_UNUSED(input) + if (!m_index.isValid()) + return; QPoint pos = m_view->mapToGlobal(m_view->visualRect(m_index).topLeft()); pos -= Utils::ToolTip::offsetFromPosition(); Utils::ToolTip::show(pos, m_toolTipText); diff --git a/src/libs/utils/namevaluevalidator.h b/src/libs/utils/namevaluevalidator.h index 508fc78e54f..c81dbe2e5bd 100644 --- a/src/libs/utils/namevaluevalidator.h +++ b/src/libs/utils/namevaluevalidator.h @@ -29,6 +29,7 @@ #include "utils_global.h" #include +#include #include #include @@ -52,7 +53,7 @@ private: const QString m_toolTipText; Utils::NameValueModel *m_model; QTreeView *m_view; - QModelIndex m_index; + QPersistentModelIndex m_index; mutable QTimer m_hideTipTimer; }; } // namespace Utils From 000268e40c03626adf82585c83a6670ca98d3d57 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 8 Jan 2021 10:23:10 +0100 Subject: [PATCH 2/8] Fix compilation with Qt 6 No QRegExp in Qt 6 anymore, use QRegularExpression. Amends bebd70573e75c294e1638b7e5436fe603ca978a4 Task-number: QTCREATORBUG-24098 Change-Id: I1f65a400d27d710b6393fb3568e8fc020ccb194e Reviewed-by: Thomas Hartmann --- .../components/bindingeditor/signallist.cpp | 4 ++-- .../components/bindingeditor/signallistdialog.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/components/bindingeditor/signallist.cpp b/src/plugins/qmldesigner/components/bindingeditor/signallist.cpp index c3f0ddb0e58..915518c67a7 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/signallist.cpp +++ b/src/plugins/qmldesigner/components/bindingeditor/signallist.cpp @@ -74,8 +74,8 @@ bool SignalListFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s QModelIndex targetIndex = sourceModel()->index(sourceRow, SignalListModel::TargetColumn, sourceParent); QModelIndex signalIndex = sourceModel()->index(sourceRow, SignalListModel::SignalColumn, sourceParent); - return (sourceModel()->data(targetIndex).toString().contains(filterRegExp()) - || sourceModel()->data(signalIndex).toString().contains(filterRegExp())); + return (sourceModel()->data(targetIndex).toString().contains(filterRegularExpression()) + || sourceModel()->data(signalIndex).toString().contains(filterRegularExpression())); } diff --git a/src/plugins/qmldesigner/components/bindingeditor/signallistdialog.cpp b/src/plugins/qmldesigner/components/bindingeditor/signallistdialog.cpp index fde8c9649b8..faa04ab3b72 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/signallistdialog.cpp +++ b/src/plugins/qmldesigner/components/bindingeditor/signallistdialog.cpp @@ -118,8 +118,14 @@ void SignalListDialog::initialize(QStandardItemModel *model) header->setStretchLastSection(false); auto eventFilterFun = [this](const QString &str) { - if (auto *fm = qobject_cast(m_table->model())) - fm->setFilterFixedString(str); + if (auto *fm = qobject_cast(m_table->model())) { + const QRegularExpression::PatternOption option + = fm->filterCaseSensitivity() == Qt::CaseInsensitive + ? QRegularExpression::CaseInsensitiveOption + : QRegularExpression::NoPatternOption; + fm->setFilterRegularExpression( + QRegularExpression(QRegularExpression::escape(str), option)); + } }; connect(m_searchLine, &Utils::FancyLineEdit::filterChanged, eventFilterFun); } From 47dfc16eee2526e8e46ab8866ae88a550688b8c5 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 8 Jan 2021 12:44:07 +0100 Subject: [PATCH 3/8] ClangCodeModel: Work around race condition when closing editors The editor manager emits currentEditorChanged() before editorsClosed(), which throws off the clangbackend. Fix this by sending an extra DocumentVisibilityChangedMessage after the DocumentsClosedMessage. Fixes: QTCREATORBUG-25193 Change-Id: Ic02ae174a2912d79aeded44ced13d962b53526b1 Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangbackendcommunicator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/clangcodemodel/clangbackendcommunicator.cpp b/src/plugins/clangcodemodel/clangbackendcommunicator.cpp index 69e021cf56d..563e45adc6a 100644 --- a/src/plugins/clangcodemodel/clangbackendcommunicator.cpp +++ b/src/plugins/clangcodemodel/clangbackendcommunicator.cpp @@ -478,6 +478,7 @@ void BackendCommunicator::documentsClosed(const FileContainers &fileContainers) { const DocumentsClosedMessage message(fileContainers); m_sender->documentsClosed(message); + documentVisibilityChanged(); // QTCREATORBUG-25193 } void BackendCommunicator::unsavedFilesUpdated(const FileContainers &fileContainers) From c109b60cdfc7badcfcc44791ec39fd6cf5733789 Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Thu, 24 Dec 2020 01:42:10 +0100 Subject: [PATCH 4/8] CPlusPlus lib: Add support for BINDABLE in Q_PROPERTY Change-Id: I8ca00aff63261eea997267d41b12c2397d676748 Reviewed-by: Christian Kandeler --- src/libs/3rdparty/cplusplus/Parser.cpp | 2 ++ .../3rdparty/cplusplus/QtContextKeywords.cpp | 17 +++++++++++++++++ src/libs/3rdparty/cplusplus/QtContextKeywords.h | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 3c509be00c0..8057aa6dc0e 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -2287,6 +2287,7 @@ bool Parser::parseAccessDeclaration(DeclarationAST *&node) [SCRIPTABLE bool] [STORED bool] [USER bool] + [BINDABLE bindableFunction] [CONSTANT] [FINAL]) @@ -2342,6 +2343,7 @@ bool Parser::parseQtPropertyDeclaration(DeclarationAST *&node) case Token_READ: case Token_WRITE: case Token_MEMBER: + case Token_BINDABLE: case Token_RESET: case Token_NOTIFY: case Token_REVISION: diff --git a/src/libs/3rdparty/cplusplus/QtContextKeywords.cpp b/src/libs/3rdparty/cplusplus/QtContextKeywords.cpp index ce7bd0a1dde..f903b2b9b21 100644 --- a/src/libs/3rdparty/cplusplus/QtContextKeywords.cpp +++ b/src/libs/3rdparty/cplusplus/QtContextKeywords.cpp @@ -159,6 +159,23 @@ static inline int classify8(const char *s) { } } } + if (s[0] == 'B') { + if (s[1] == 'I') { + if (s[2] == 'N') { + if (s[3] == 'D') { + if (s[4] == 'A') { + if (s[5] == 'B') { + if (s[6] == 'L') { + if (s[7] == 'E') { + return Token_BINDABLE; + } + } + } + } + } + } + } + } return Token_not_Qt_context_keyword; } diff --git a/src/libs/3rdparty/cplusplus/QtContextKeywords.h b/src/libs/3rdparty/cplusplus/QtContextKeywords.h index 42dce9b917d..f5d39a49cfc 100644 --- a/src/libs/3rdparty/cplusplus/QtContextKeywords.h +++ b/src/libs/3rdparty/cplusplus/QtContextKeywords.h @@ -37,7 +37,8 @@ enum { Token_DESIGNABLE, Token_SCRIPTABLE, Token_REVISION, - Token_MEMBER + Token_MEMBER, + Token_BINDABLE }; CPLUSPLUS_EXPORT int classifyQtContextKeyword(const char *s, int n); From ac32cf56a1c73aa7178cf9081fbf1e3a47a6a438 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 7 Jan 2021 09:25:23 +0200 Subject: [PATCH 5/8] Debugger: Add -file-exec-file when opening a core dump -file-symbol-file alone doesn't cover all cases. Run -file-exec-file too. Task-number: QTCREATORBUG-24541 Change-Id: Id4d8f7057f845bce32b28cc8f4db0eadcfcfab28 Reviewed-by: hjk --- src/plugins/debugger/gdb/gdbengine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 98444776787..e401ca62599 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4194,6 +4194,9 @@ void GdbEngine::setupInferior() // Do that first, otherwise no symbols are loaded. QFileInfo fi = executable.toFileInfo(); QString path = fi.absoluteFilePath(); + // This is *not* equivalent to -file-exec-and-symbols. If the file is not executable + // (contains only debugging symbols), this should still work. + runCommand({"-file-exec-file \"" + path + '"'}); runCommand({"-file-symbol-file \"" + path + '"', CB(handleFileExecAndSymbols)}); From 86348d562214a27574ddbd65825414ae7e731438 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 11 Jan 2021 13:33:48 +0100 Subject: [PATCH 6/8] cmake build: Fix fallback LLVM/Clang paths CLANG_INCLUDE_DIR and CLANG_BINDIR are the fallback paths that are used if no bundled LLVM/Clang is found, so these must be absolute paths to the build-time LLVM/Clang installation. This also removes the need of copying LLVM/Clang into Qt Creator's build directory. Fixes: QTCREATORBUG-25147 Change-Id: I052138d894c316f493423b1da0ba79af633c4c37 Reviewed-by: Cristian Adam --- src/libs/clangsupport/CMakeLists.txt | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/libs/clangsupport/CMakeLists.txt b/src/libs/clangsupport/CMakeLists.txt index dcaa4647101..93487a9f946 100644 --- a/src/libs/clangsupport/CMakeLists.txt +++ b/src/libs/clangsupport/CMakeLists.txt @@ -5,8 +5,8 @@ add_qtc_library(ClangSupport PUBLIC_DEPENDS Utils Sqlite Qt5::Core Qt5::Network PUBLIC_DEFINES CLANG_VERSION="${CLANG_VERSION}" - CLANG_INCLUDE_DIR="${IDE_LIBEXEC_PATH}/clang/lib/clang/${CLANG_VERSION}/include" - CLANG_BINDIR="${IDE_LIBEXEC_PATH}/clang/bin" + CLANG_INCLUDE_DIR="${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}/include" + CLANG_BINDIR="${LLVM_TOOLS_BINARY_DIR}" DEFINES CLANGSUPPORT_BUILD_LIB PUBLIC_INCLUDES "${CMAKE_CURRENT_LIST_DIR}" @@ -146,18 +146,3 @@ add_qtc_library(ClangSupport if (NOT TARGET libclang) return() endif() - -# For the developer build directory -qtc_copy_to_builddir(copy_clang_to_builddir - DIRECTORIES "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}/include" - DESTINATION "${IDE_LIBEXEC_PATH}/clang/lib/clang/${CLANG_VERSION}/include" -) - -foreach(executable clang clang-cl clangd clang-tidy clazy-standalone) - if (EXISTS "${LLVM_TOOLS_BINARY_DIR}/${executable}${CMAKE_EXECUTABLE_SUFFIX}") - qtc_copy_to_builddir(copy_clang_${executable}_to_builddir - FILES "${LLVM_TOOLS_BINARY_DIR}/${executable}${CMAKE_EXECUTABLE_SUFFIX}" - DESTINATION "${IDE_LIBEXEC_PATH}/clang/bin/" - ) - endif() -endforeach() From 85bdcf819f2b599b977ea87bcd9160c04a98259e Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 11 Jan 2021 08:25:06 +0100 Subject: [PATCH 7/8] Utils: Only write data to process if there is any This avoids the warning QIODevice::write (QProcess): ReadOnly device in cases where the process is run inside a read only directory even when the process has no input. Change-Id: I9434c738e9cf94c348f1437ebf15e1c7574cde94 Reviewed-by: Eike Ziller Reviewed-by: hjk --- src/libs/utils/synchronousprocess.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index 0845e4b8034..d722801efb6 100644 --- a/src/libs/utils/synchronousprocess.cpp +++ b/src/libs/utils/synchronousprocess.cpp @@ -481,10 +481,12 @@ SynchronousProcessResponse SynchronousProcess::run(const CommandLine &cmd, // only with the OpenMode d->m_process.setProgram(cmd.executable().toString()); d->m_process.setArguments(cmd.splitArguments()); - connect(&d->m_process, &QProcess::started, this, [this, writeData] { - d->m_process.write(writeData); - d->m_process.closeWriteChannel(); - }); + if (!writeData.isEmpty()) { + connect(&d->m_process, &QProcess::started, this, [this, writeData] { + d->m_process.write(writeData); + d->m_process.closeWriteChannel(); + }); + } d->m_process.start(writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite); // On Windows, start failure is triggered immediately if the From 4231a88b67abe9ce2bfcffedc589a262c230d642 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 6 Jan 2021 16:12:01 +0100 Subject: [PATCH 8/8] ProjectExplorer: Add more variables for active project Fixes: QTCREATORBUG-25206 Change-Id: I3826824de73ef15138e037a7134592e4aa13130f Reviewed-by: Eike Ziller --- .../projectexplorer/projectexplorer.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 16970638495..10e18d89e0c 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -328,10 +328,15 @@ static BuildConfiguration *currentBuildConfiguration() return target ? target->activeBuildConfiguration() : nullptr; } -static BuildConfiguration *activeBuildConfiguration() +static Target *activeTarget() { const Project * const project = SessionManager::startupProject(); - const Target * const target = project ? project->activeTarget() : nullptr; + return project ? project->activeTarget() : nullptr; +} + +static BuildConfiguration *activeBuildConfiguration() +{ + const Target * const target = activeTarget(); return target ? target->activeBuildConfiguration() : nullptr; } @@ -1823,6 +1828,20 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er return project->projectFilePath().toString(); return {}; }); + expander->registerVariable("ActiveProject:Kit:Name", + "The name of the active project's active kit.", // TODO: tr() + []() -> QString { + if (const Target * const target = activeTarget()) + return target->kit()->displayName(); + return {}; + }); + expander->registerVariable("ActiveProject:BuildConfig:Name", + "The name of the active project's active build configuration.", // TODO: tr() + []() -> QString { + if (const BuildConfiguration * const bc = activeBuildConfiguration()) + return bc->displayName(); + return {}; + }); expander->registerVariable("ActiveProject:BuildConfig:Type", tr("The type of the active project's active build configuration."), []() -> QString {