Merge remote-tracking branch 'origin/9.0'

Conflicts:
	src/plugins/cppeditor/cppelementevaluator.cpp
	src/plugins/vcsbase/vcsbaseclient.cpp

Change-Id: I31e03b063240416280f5ca88c31f432911d5c67e
This commit is contained in:
Eike Ziller
2022-12-12 11:07:15 +01:00
17 changed files with 207 additions and 112 deletions

99
dist/changelog/changes-9.0.1.md vendored Normal file
View File

@@ -0,0 +1,99 @@
Qt Creator 9.0.1
================
Qt Creator version 9.0.1 contains bug fixes.
The most important changes are listed in this document. For a complete list of
changes, see the Git log for the Qt Creator sources that you can check out from
the public Git repository. For example:
git clone git://code.qt.io/qt-creator/qt-creator.git
git log --cherry-pick --pretty=oneline origin/v9.0.0..v9.0.1
General
-------
* Improved performance in the context of file path handling
* Fixed missing `No updates found.` message after looking for updates
* Fixed loading of custom external tools definitions
Editing
-------
* Fixed double `*` sign at end of long document names in dropdown
### C++
* Fixed jumping to wrong symbol with `Follow Symbol` (QTCREATORBUG-28452)
* Fixed display of tab size in code style settings (QTCREATORBUG-28450)
* Fixed crash after closing settings when opened from indexing progress
(QTCREATORBUG-28566)
* Fixed crash when opening type hierarchy (QTCREATORBUG-28529)
Projects
--------
### CMake
* Fixed that build environment was not migrated to the new configuration
environment (QTCREATORBUG-28372)
* Fixed handling of `inherits` for deeper hierarchies (QTCREATORBUG-28498)
Debugging
---------
* Fixed handling of macros in source path mapping (QTCREATORBUG-28484)
### GDB
* Fixed pretty printer of `std::string` from `libc++` (QTCREATORBUG-28511)
### CDB
* Fixed source path mapping (QTCREATORBUG-28521)
Analyzer
--------
### Clang
* Fixed crash when clearing selection in settings (QTCREATORBUG-28524)
Test Integration
----------------
### Google Test
* Fixed debugging (QTCREATORBUG-28504)
Platforms
---------
### Linux
* Fixed wrong colors with GTK3 platform theme (QTCREATORBUG-28497)
### Docker
* Fixed that working directory for remote processes was not made reachable
Credits for these changes go to:
--------------------------------
Alessandro Portale
André Pönitz
Artem Sokolovskii
Christian Kandeler
Christian Stenger
Cristian Adam
David Schulz
Eike Ziller
Jaroslaw Kobus
Kai Köhne
Kwangsub Kim
Leena Miettinen
Marcus Tillmanns
Orgad Shaneh
Riitta-Leena Miettinen
Thomas Hartmann
Tim Jenssen
Ulf Hermann

View File

@@ -415,10 +415,10 @@ Toolchains IarToolChainFactory::autoDetect(const ToolchainDetector &detector) co
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
QStringList registryNodes;
registryNodes << "HKEY_LOCAL_MACHINE\\SOFTWARE\\IAR Systems\\Embedded Workbench";
#ifdef Q_OS_WIN64 #ifdef Q_OS_WIN64
static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\IAR Systems\\Embedded Workbench"; registryNodes << "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\IAR Systems\\Embedded Workbench";
#else
static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\IAR Systems\\Embedded Workbench";
#endif #endif
// Dictionary for know toolchains. // Dictionary for know toolchains.
@@ -446,7 +446,8 @@ Toolchains IarToolChainFactory::autoDetect(const ToolchainDetector &detector) co
{{"EWCR16C"}, {"/cr16c/bin/icccr16c.exe"}}, {{"EWCR16C"}, {"/cr16c/bin/icccr16c.exe"}},
}; };
QSettings registry(kRegistryNode, QSettings::NativeFormat); for (const QString &registryNode : registryNodes) {
QSettings registry(registryNode, QSettings::NativeFormat);
const auto oneLevelGroups = registry.childGroups(); const auto oneLevelGroups = registry.childGroups();
for (const QString &oneLevelKey : oneLevelGroups) { for (const QString &oneLevelKey : oneLevelGroups) {
registry.beginGroup(oneLevelKey); registry.beginGroup(oneLevelKey);
@@ -474,6 +475,7 @@ Toolchains IarToolChainFactory::autoDetect(const ToolchainDetector &detector) co
} }
registry.endGroup(); registry.endGroup();
} }
}
#endif // Q_OS_WIN #endif // Q_OS_WIN

View File

@@ -394,7 +394,12 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
project ? tr("Indexing %1 with clangd").arg(project->displayName()) project ? tr("Indexing %1 with clangd").arg(project->displayName())
: tr("Indexing session with clangd")); : tr("Indexing session with clangd"));
setClickHandlerForToken(indexingToken(), [] { setClickHandlerForToken(indexingToken(), [] {
ICore::showOptionsDialog(CppEditor::Constants::CPP_CLANGD_SETTINGS_ID); // don't directly open modal dialog from click handler, because that would mess
// up the stack
QMetaObject::invokeMethod(
ICore::instance(),
[] { ICore::showOptionsDialog(CppEditor::Constants::CPP_CLANGD_SETTINGS_ID); },
Qt::QueuedConnection);
}); });
setCurrentProject(project); setCurrentProject(project);
setDocumentChangeUpdateThreshold(d->settings.documentUpdateThreshold); setDocumentChangeUpdateThreshold(d->settings.documentUpdateThreshold);

View File

@@ -55,7 +55,6 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent, const QList<IDocument *> &item
} }
m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save);
QPushButton *discardButton = m_buttonBox->addButton(tr("Do &Not Save"), discardButtonRole); QPushButton *discardButton = m_buttonBox->addButton(tr("Do &Not Save"), discardButtonRole);
m_buttonBox->button(QDialogButtonBox::Save)->setDefault(true);
m_treeWidget->setFocus(); m_treeWidget->setFocus();
m_saveBeforeBuildCheckBox->setVisible(false); m_saveBeforeBuildCheckBox->setVisible(false);
@@ -103,6 +102,8 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent, const QList<IDocument *> &item
&SaveItemsDialog::collectItemsToSave); &SaveItemsDialog::collectItemsToSave);
connect(discardButton, &QAbstractButton::clicked, this, &SaveItemsDialog::discardAll); connect(discardButton, &QAbstractButton::clicked, this, &SaveItemsDialog::discardAll);
connect(m_treeWidget, &QTreeWidget::itemSelectionChanged, this, &SaveItemsDialog::updateButtons); connect(m_treeWidget, &QTreeWidget::itemSelectionChanged, this, &SaveItemsDialog::updateButtons);
m_buttonBox->button(QDialogButtonBox::Save)->setDefault(true);
} }
void SaveItemsDialog::setMessage(const QString &msg) void SaveItemsDialog::setMessage(const QString &msg)

View File

@@ -445,11 +445,6 @@ void CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged()
if (m_blockUpdates) if (m_blockUpdates)
return; return;
if (m_preferences) {
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
if (current)
current->setCodeStyleSettings(cppCodeStyleSettings());
}
emit codeStyleSettingsChanged(cppCodeStyleSettings()); emit codeStyleSettingsChanged(cppCodeStyleSettings());
updatePreview(); updatePreview();
} }
@@ -459,12 +454,6 @@ void CppCodeStylePreferencesWidget::slotTabSettingsChanged(const TabSettings &se
if (m_blockUpdates) if (m_blockUpdates)
return; return;
if (m_preferences) {
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
if (current)
current->setTabSettings(settings);
}
emit tabSettingsChanged(settings); emit tabSettingsChanged(settings);
updatePreview(); updatePreview();
} }
@@ -547,6 +536,14 @@ void CppCodeStylePreferencesWidget::addTab(CppCodeStyleWidget *page, QString tab
void CppCodeStylePreferencesWidget::apply() void CppCodeStylePreferencesWidget::apply()
{ {
if (m_preferences) {
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
if (current) {
current->setTabSettings(tabSettings());
current->setCodeStyleSettings(cppCodeStyleSettings());
}
}
emit applyEmitted(); emit applyEmitted();
} }

View File

@@ -95,8 +95,7 @@ public:
// CppDeclarableElement // CppDeclarableElement
CppDeclarableElement::CppDeclarableElement(Symbol *declaration) CppDeclarableElement::CppDeclarableElement(Symbol *declaration)
: CppElement() : CppElement()
, declaration(declaration) , iconType(CPlusPlus::Icons::iconTypeForSymbol(declaration))
, icon(CPlusPlus::Icons::iconForSymbol(declaration))
{ {
Overview overview; Overview overview;
overview.showArgumentNames = true; overview.showArgumentNames = true;
@@ -136,11 +135,6 @@ CppClass::CppClass(Symbol *declaration) : CppDeclarableElement(declaration)
tooltip = qualifiedName; tooltip = qualifiedName;
} }
bool CppClass::operator==(const CppClass &other)
{
return this->declaration == other.declaration;
}
CppClass *CppClass::toCppClass() CppClass *CppClass::toCppClass()
{ {
return this; return this;
@@ -149,32 +143,30 @@ CppClass *CppClass::toCppClass()
void CppClass::lookupBases(QFutureInterfaceBase &futureInterface, void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
Symbol *declaration, const LookupContext &context) Symbol *declaration, const LookupContext &context)
{ {
using Data = QPair<ClassOrNamespace*, CppClass*>; ClassOrNamespace *hierarchy = context.lookupType(declaration);
if (!hierarchy)
if (ClassOrNamespace *clazz = context.lookupType(declaration)) { return;
QSet<ClassOrNamespace *> visited; QSet<ClassOrNamespace *> visited;
addBaseHierarchy(futureInterface, context, hierarchy, &visited);
}
QQueue<Data> q; void CppClass::addBaseHierarchy(QFutureInterfaceBase &futureInterface, const LookupContext &context,
q.enqueue({clazz, this}); ClassOrNamespace *hierarchy, QSet<ClassOrNamespace *> *visited)
while (!q.isEmpty()) { {
if (futureInterface.isCanceled()) if (futureInterface.isCanceled())
return; return;
Data current = q.dequeue(); visited->insert(hierarchy);
clazz = current.first; const QList<ClassOrNamespace *> &baseClasses = hierarchy->usings();
visited.insert(clazz); for (ClassOrNamespace *baseClass : baseClasses) {
const QList<ClassOrNamespace *> &bases = clazz->usings();
for (ClassOrNamespace *baseClass : bases) {
const QList<Symbol *> &symbols = baseClass->symbols(); const QList<Symbol *> &symbols = baseClass->symbols();
for (Symbol *symbol : symbols) { for (Symbol *symbol : symbols) {
if (symbol->asClass() && ( if (!symbol->asClass())
clazz = context.lookupType(symbol)) && continue;
!visited.contains(clazz)) { ClassOrNamespace *baseHierarchy = context.lookupType(symbol);
CppClass baseCppClass(symbol); if (baseHierarchy && !visited->contains(baseHierarchy)) {
CppClass *cppClass = current.second; CppClass classSymbol(symbol);
cppClass->bases.append(baseCppClass); classSymbol.addBaseHierarchy(futureInterface, context, baseHierarchy, visited);
q.enqueue({clazz, &cppClass->bases.last()}); bases.append(classSymbol);
}
}
} }
} }
} }
@@ -183,28 +175,20 @@ void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
void CppClass::lookupDerived(QFutureInterfaceBase &futureInterface, void CppClass::lookupDerived(QFutureInterfaceBase &futureInterface,
Symbol *declaration, const Snapshot &snapshot) Symbol *declaration, const Snapshot &snapshot)
{ {
using Data = QPair<CppClass*, TypeHierarchy>;
snapshot.updateDependencyTable(futureInterface); snapshot.updateDependencyTable(futureInterface);
if (futureInterface.isCanceled()) if (futureInterface.isCanceled())
return; return;
const TypeHierarchy &completeHierarchy addDerivedHierarchy(TypeHierarchyBuilder::buildDerivedTypeHierarchy(
= TypeHierarchyBuilder::buildDerivedTypeHierarchy(futureInterface, declaration, snapshot); futureInterface, declaration, snapshot));
}
QQueue<Data> q; void CppClass::addDerivedHierarchy(const TypeHierarchy &hierarchy)
q.enqueue({this, completeHierarchy}); {
while (!q.isEmpty()) { CppClass classSymbol(hierarchy.symbol());
if (futureInterface.isCanceled()) const QList<TypeHierarchy> derivedHierarchies = hierarchy.hierarchy();
return; for (const TypeHierarchy &derivedHierarchy : derivedHierarchies)
const Data &current = q.dequeue(); classSymbol.addDerivedHierarchy(derivedHierarchy);
CppClass *clazz = current.first; derived.append(classSymbol);
const TypeHierarchy &classHierarchy = current.second;
const QList<TypeHierarchy> hierarchy = classHierarchy.hierarchy();
for (const TypeHierarchy &derivedHierarchy : hierarchy) {
clazz->derived.append(CppClass(derivedHierarchy.symbol()));
q.enqueue({&clazz->derived.last(), derivedHierarchy});
}
}
} }
class CppFunction : public CppDeclarableElement class CppFunction : public CppDeclarableElement

View File

@@ -3,13 +3,14 @@
#pragma once #pragma once
#include <coreplugin/helpitem.h> #include "typehierarchybuilder.h"
#include <texteditor/texteditor.h>
#include <coreplugin/helpitem.h>
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
#include <texteditor/texteditor.h>
#include <utils/utilsicons.h>
#include <QFuture> #include <QFuture>
#include <QIcon>
#include <QSharedPointer> #include <QSharedPointer>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
@@ -18,6 +19,7 @@
#include <functional> #include <functional>
namespace CPlusPlus { namespace CPlusPlus {
class ClassOrNamespace;
class LookupItem; class LookupItem;
class LookupContext; class LookupContext;
} }
@@ -76,11 +78,10 @@ public:
explicit CppDeclarableElement(CPlusPlus::Symbol *declaration); explicit CppDeclarableElement(CPlusPlus::Symbol *declaration);
public: public:
CPlusPlus::Symbol *declaration; Utils::CodeModelIcon::Type iconType;
QString name; QString name;
QString qualifiedName; QString qualifiedName;
QString type; QString type;
QIcon icon;
}; };
class CppClass : public CppDeclarableElement class CppClass : public CppDeclarableElement
@@ -89,8 +90,6 @@ public:
CppClass(); CppClass();
explicit CppClass(CPlusPlus::Symbol *declaration); explicit CppClass(CPlusPlus::Symbol *declaration);
bool operator==(const CppClass &other);
CppClass *toCppClass() final; CppClass *toCppClass() final;
void lookupBases(QFutureInterfaceBase &futureInterface, void lookupBases(QFutureInterfaceBase &futureInterface,
@@ -98,9 +97,15 @@ public:
void lookupDerived(QFutureInterfaceBase &futureInterface, void lookupDerived(QFutureInterfaceBase &futureInterface,
CPlusPlus::Symbol *declaration, const CPlusPlus::Snapshot &snapshot); CPlusPlus::Symbol *declaration, const CPlusPlus::Snapshot &snapshot);
public:
QList<CppClass> bases; QList<CppClass> bases;
QList<CppClass> derived; QList<CppClass> derived;
private:
void addBaseHierarchy(QFutureInterfaceBase &futureInterface,
const CPlusPlus::LookupContext &context,
CPlusPlus::ClassOrNamespace *hierarchy,
QSet<CPlusPlus::ClassOrNamespace *> *visited);
void addDerivedHierarchy(const TypeHierarchy &hierarchy);
}; };
} // namespace Internal } // namespace Internal

View File

@@ -4309,6 +4309,8 @@ void GenerateGetterSetter::match(const CppQuickFixInterface &interface, QuickFix
return; return;
declarator = path.at(n - i++)->asDeclarator(); declarator = path.at(n - i++)->asDeclarator();
} }
if (!declarator)
return;
} }
const auto variableDecl = path.at(n - i++)->asSimpleDeclaration(); const auto variableDecl = path.at(n - i++)->asSimpleDeclaration();
const auto classSpecifier = path.at(n - i++)->asClassSpecifier(); const auto classSpecifier = path.at(n - i++)->asClassSpecifier();

View File

@@ -44,7 +44,7 @@ QStandardItem *itemForClass(const CppClass &cppClass)
item->setData(cppClass.name, Qt::DisplayRole); item->setData(cppClass.name, Qt::DisplayRole);
if (cppClass.name != cppClass.qualifiedName) if (cppClass.name != cppClass.qualifiedName)
item->setData(cppClass.qualifiedName, AnnotationRole); item->setData(cppClass.qualifiedName, AnnotationRole);
item->setData(cppClass.icon, Qt::DecorationRole); item->setData(iconForType(cppClass.iconType), Qt::DecorationRole);
QVariant link; QVariant link;
link.setValue(Link(cppClass.link)); link.setValue(Link(cppClass.link));
item->setData(link, LinkRole); item->setData(link, LinkRole);

View File

@@ -111,10 +111,12 @@ void McuSdkRepository::expandVariablesAndWildcards()
continue; continue;
} }
// drop empty_split_entry(linux)|root(windows) // drop empty_split_entry(linux)|root(windows)
pathComponents.pop_front(); QString root = pathComponents.takeFirst();
if (root.isEmpty()) // Linux
root = "/";
package->setPath( package->setPath(
expandWildcards(FilePath::fromString(QDir::rootPath()), expandWildcards(FilePath::fromString(root),
{pathComponents.constBegin(), pathComponents.constEnd()}) {pathComponents.constBegin(), pathComponents.constEnd()})
.first); .first);
} }

View File

@@ -2107,8 +2107,10 @@ std::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils::E
saver.write("set CLINK_NOAUTORUN=1\r\n"); saver.write("set CLINK_NOAUTORUN=1\r\n");
saver.write("setlocal enableextensions\r\n"); saver.write("setlocal enableextensions\r\n");
saver.write("if defined VCINSTALLDIR (\r\n"); saver.write("if defined VCINSTALLDIR (\r\n");
saver.write(" if not defined QTC_NO_MSVC_CLEAN_ENV (\r\n");
saver.write(" call \"%VCINSTALLDIR%/Auxiliary/Build/vcvarsall.bat\" /clean_env\r\n"); saver.write(" call \"%VCINSTALLDIR%/Auxiliary/Build/vcvarsall.bat\" /clean_env\r\n");
saver.write(" )\r\n"); saver.write(" )\r\n");
saver.write(")\r\n");
saver.write(call + "\r\n"); saver.write(call + "\r\n");
saver.write("@echo " + marker.toLocal8Bit() + "\r\n"); saver.write("@echo " + marker.toLocal8Bit() + "\r\n");
saver.write("set\r\n"); saver.write("set\r\n");

View File

@@ -306,20 +306,17 @@ QString PluginGenerator::processTemplate(const QString &tmpl,
{ {
Utils::FileReader reader; Utils::FileReader reader;
if (!reader.fetch(Utils::FilePath::fromString(tmpl), errorMessage)) if (!reader.fetch(Utils::FilePath::fromString(tmpl), errorMessage))
return QString(); return {};
QString cont = QString::fromUtf8(reader.data()); QString cont = QString::fromUtf8(reader.data());
// Expander needed to handle extra variable "Cpp:PragmaOnce" // Expander needed to handle extra variable "Cpp:PragmaOnce"
Utils::MacroExpander *expander = Utils::globalMacroExpander(); Utils::MacroExpander *expander = Utils::globalMacroExpander();
QString errMsg; cont = Utils::TemplateEngine::processText(expander, cont, errorMessage);
cont = Utils::TemplateEngine::processText(expander, cont, &errMsg); if (!errorMessage->isEmpty()) {
if (!errMsg.isEmpty()) {
qWarning("Error processing custom plugin file: %s\nFile:\n%s", qWarning("Error processing custom plugin file: %s\nFile:\n%s",
qPrintable(errMsg), qPrintable(cont)); qPrintable(*errorMessage), qPrintable(cont));
errorMessage = &errMsg; return {};
return QString();
} }
const QChar atChar = QLatin1Char('@'); const QChar atChar = QLatin1Char('@');

View File

@@ -1020,7 +1020,7 @@ Utils::Links SquishTools::setBreakpoints()
continue; continue;
const Utils::FilePath filePath = Utils::FilePath::fromString( const Utils::FilePath filePath = Utils::FilePath::fromString(
gb->data(BreakpointFileColumn, Qt::DisplayRole).toString()); gb->data(BreakpointFileColumn, Qt::DisplayRole).toString());
auto fileName = filePath.toUserOutput(); auto fileName = filePath.canonicalPath().toUserOutput();
if (fileName.isEmpty()) if (fileName.isEmpty())
continue; continue;
if (!fileName.endsWith(extension)) if (!fileName.endsWith(extension))

View File

@@ -7850,7 +7850,7 @@ struct MappedText
void TextEditorWidget::insertFromMimeData(const QMimeData *source) void TextEditorWidget::insertFromMimeData(const QMimeData *source)
{ {
if (isReadOnly()) if (!source || isReadOnly())
return; return;
QString text = source->text(); QString text = source->text();
@@ -7860,7 +7860,6 @@ void TextEditorWidget::insertFromMimeData(const QMimeData *source)
if (d->m_codeAssistant.hasContext()) if (d->m_codeAssistant.hasContext())
d->m_codeAssistant.destroyContext(); d->m_codeAssistant.destroyContext();
if (d->m_snippetOverlay->isVisible() && (text.contains('\n') || text.contains('\t'))) if (d->m_snippetOverlay->isVisible() && (text.contains('\n') || text.contains('\t')))
d->m_snippetOverlay->accept(); d->m_snippetOverlay->accept();

View File

@@ -454,7 +454,7 @@ void VcsBaseClient::revertAll(const FilePath &workingDir,
if (cmd->result() == ProcessResult::FinishedWithSuccess) if (cmd->result() == ProcessResult::FinishedWithSuccess)
emit changed(files); emit changed(files);
}); });
enqueueJob(createCommand(workingDir), args); enqueueJob(cmd, args);
} }
void VcsBaseClient::status(const FilePath &workingDir, void VcsBaseClient::status(const FilePath &workingDir,