Merge "Merge remote-tracking branch 'origin/4.15'"

This commit is contained in:
The Qt Project
2021-06-07 08:03:24 +00:00
13 changed files with 114 additions and 56 deletions

View File

@@ -286,6 +286,10 @@ void CMakeBuildSystem::triggerParsing()
reparseParameters |= REPARSE_FORCE_CMAKE_RUN | REPARSE_FORCE_EXTRA_CONFIGURATION; reparseParameters |= REPARSE_FORCE_CMAKE_RUN | REPARSE_FORCE_EXTRA_CONFIGURATION;
} }
// The code model will be updated after the CMake run. There is no need to have an
// active code model updater when the next one will be triggered.
m_cppCodeModelUpdater->cancel();
qCDebug(cmakeBuildSystemLog) << "Asking reader to parse"; qCDebug(cmakeBuildSystemLog) << "Asking reader to parse";
m_reader.parse(reparseParameters & REPARSE_FORCE_CMAKE_RUN, m_reader.parse(reparseParameters & REPARSE_FORCE_CMAKE_RUN,
reparseParameters & REPARSE_FORCE_INITIAL_CONFIGURATION, reparseParameters & REPARSE_FORCE_INITIAL_CONFIGURATION,
@@ -370,27 +374,6 @@ QString CMakeBuildSystem::reparseParametersString(int reparseFlags)
return result.trimmed(); return result.trimmed();
} }
void CMakeBuildSystem::writeConfigurationIntoBuildDirectory()
{
const MacroExpander *expander = cmakeBuildConfiguration()->macroExpander();
const FilePath buildDir = workDirectory(m_parameters);
QTC_ASSERT(buildDir.exists(), return );
const FilePath settingsFile = buildDir.pathAppended("qtcsettings.cmake");
QByteArray contents;
contents.append("# This file is managed by Qt Creator, do not edit!\n\n");
contents.append(
transform(cmakeBuildConfiguration()->configurationChanges(),
[expander](const CMakeConfigItem &item) { return item.toCMakeSetLine(expander); })
.join('\n')
.toUtf8());
QFile file(settingsFile.toString());
QTC_ASSERT(file.open(QFile::WriteOnly | QFile::Truncate), return );
file.write(contents);
}
void CMakeBuildSystem::setParametersAndRequestParse(const BuildDirParameters &parameters, void CMakeBuildSystem::setParametersAndRequestParse(const BuildDirParameters &parameters,
const int reparseParameters) const int reparseParameters)
{ {
@@ -424,8 +407,6 @@ void CMakeBuildSystem::setParametersAndRequestParse(const BuildDirParameters &pa
m_reader.setParameters(m_parameters); m_reader.setParameters(m_parameters);
writeConfigurationIntoBuildDirectory();
if (reparseParameters & REPARSE_URGENT) { if (reparseParameters & REPARSE_URGENT) {
qCDebug(cmakeBuildSystemLog) << "calling requestReparse"; qCDebug(cmakeBuildSystemLog) << "calling requestReparse";
requestParse(); requestParse();

View File

@@ -158,8 +158,6 @@ private:
void runCTest(); void runCTest();
void writeConfigurationIntoBuildDirectory();
ProjectExplorer::TreeScanner m_treeScanner; ProjectExplorer::TreeScanner m_treeScanner;
QHash<QString, bool> m_mimeBinaryCache; QHash<QString, bool> m_mimeBinaryCache;
QList<const ProjectExplorer::FileNode *> m_allFiles; QList<const ProjectExplorer::FileNode *> m_allFiles;

View File

@@ -200,7 +200,7 @@ QString CMakeConfigItem::expandedValue(const ProjectExplorer::Kit *k) const
QString CMakeConfigItem::expandedValue(const Utils::MacroExpander *expander) const QString CMakeConfigItem::expandedValue(const Utils::MacroExpander *expander) const
{ {
return expander->expand(QString::fromUtf8(value)); return expander ? expander->expand(QString::fromUtf8(value)) : QString::fromUtf8(value);
} }
std::function<bool (const CMakeConfigItem &a, const CMakeConfigItem &b)> CMakeConfigItem::sortOperator() std::function<bool (const CMakeConfigItem &a, const CMakeConfigItem &b)> CMakeConfigItem::sortOperator()

View File

@@ -870,7 +870,9 @@ static QStringList uniqueTargetFiles(const Configuration &config)
return files; return files;
} }
FileApiData FileApiParser::parseData(const QFileInfo &replyFileInfo, const QString &cmakeBuildType, FileApiData FileApiParser::parseData(QFutureInterface<std::shared_ptr<FileApiQtcData>> &fi,
const QFileInfo &replyFileInfo,
const QString &cmakeBuildType,
QString &errorMessage) QString &errorMessage)
{ {
QTC_CHECK(errorMessage.isEmpty()); QTC_CHECK(errorMessage.isEmpty());
@@ -878,16 +880,29 @@ FileApiData FileApiParser::parseData(const QFileInfo &replyFileInfo, const QStri
FileApiData result; FileApiData result;
const auto cancelCheck = [&fi, &errorMessage]() -> bool {
if (fi.isCanceled()) {
errorMessage = FileApiParser::tr("CMake parsing was cancelled.");
return true;
}
return false;
};
result.replyFile = readReplyFile(replyFileInfo, errorMessage); result.replyFile = readReplyFile(replyFileInfo, errorMessage);
if (cancelCheck())
return {};
result.cache = readCacheFile(result.replyFile.jsonFile("cache", replyDir), errorMessage); result.cache = readCacheFile(result.replyFile.jsonFile("cache", replyDir), errorMessage);
if (cancelCheck())
return {};
result.cmakeFiles = readCMakeFilesFile(result.replyFile.jsonFile("cmakeFiles", replyDir), result.cmakeFiles = readCMakeFilesFile(result.replyFile.jsonFile("cmakeFiles", replyDir),
errorMessage); errorMessage);
if (cancelCheck())
return {};
auto codeModels = readCodemodelFile(result.replyFile.jsonFile("codemodel", replyDir), auto codeModels = readCodemodelFile(result.replyFile.jsonFile("codemodel", replyDir),
errorMessage); errorMessage);
if (codeModels.size() == 0) { if (codeModels.size() == 0) {
errorMessage = "No CMake configuration found!"; errorMessage = "No CMake configuration found!";
qWarning() << errorMessage;
return result; return result;
} }
@@ -911,14 +926,17 @@ FileApiData FileApiParser::parseData(const QFileInfo &replyFileInfo, const QStri
.arg(cmakeBuildType) .arg(cmakeBuildType)
.arg(buildTypes.join(", ")); .arg(buildTypes.join(", "));
} }
qWarning() << errorMessage;
return result; return result;
} }
result.codemodel = std::move(*it); result.codemodel = std::move(*it);
if (cancelCheck())
return {};
const QStringList targetFiles = uniqueTargetFiles(result.codemodel); const QStringList targetFiles = uniqueTargetFiles(result.codemodel);
for (const QString &targetFile : targetFiles) { for (const QString &targetFile : targetFiles) {
if (cancelCheck())
return {};
QString targetErrorMessage; QString targetErrorMessage;
TargetDetails td = readTargetFile(replyDir.absoluteFilePath(targetFile), targetErrorMessage); TargetDetails td = readTargetFile(replyDir.absoluteFilePath(targetFile), targetErrorMessage);
if (targetErrorMessage.isEmpty()) { if (targetErrorMessage.isEmpty()) {

View File

@@ -27,6 +27,8 @@
#include "cmakeconfigitem.h" #include "cmakeconfigitem.h"
#include "fileapidataextractor.h"
#include <projectexplorer/headerpath.h> #include <projectexplorer/headerpath.h>
#include <projectexplorer/projectmacro.h> #include <projectexplorer/projectmacro.h>
@@ -34,6 +36,7 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <QDir> #include <QDir>
#include <QFutureInterface>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@@ -247,7 +250,9 @@ class FileApiParser
{ {
Q_DECLARE_TR_FUNCTIONS(FileApiParser) Q_DECLARE_TR_FUNCTIONS(FileApiParser)
public: public:
static FileApiData parseData(const QFileInfo &replyFileInfo, const QString& cmakeBuildType, static FileApiData parseData(QFutureInterface<std::shared_ptr<FileApiQtcData>> &fi,
const QFileInfo &replyFileInfo,
const QString &cmakeBuildType,
QString &errorMessage); QString &errorMessage);
static bool setupCMakeFileApi(const Utils::FilePath &buildDirectory, static bool setupCMakeFileApi(const Utils::FilePath &buildDirectory,

View File

@@ -265,11 +265,14 @@ void FileApiReader::endState(const QFileInfo &replyFi)
m_lastReplyTimestamp = replyFi.lastModified(); m_lastReplyTimestamp = replyFi.lastModified();
m_future = runAsync(ProjectExplorerPlugin::sharedThreadPool(), m_future = runAsync(ProjectExplorerPlugin::sharedThreadPool(),
[replyFi, sourceDirectory, buildDirectory, topCmakeFile, cmakeBuildType]() { [replyFi, sourceDirectory, buildDirectory, topCmakeFile, cmakeBuildType](
QFutureInterface<std::shared_ptr<FileApiQtcData>> &fi) {
auto result = std::make_shared<FileApiQtcData>(); auto result = std::make_shared<FileApiQtcData>();
FileApiData data = FileApiParser::parseData(replyFi, cmakeBuildType, result->errorMessage); FileApiData data = FileApiParser::parseData(fi,
replyFi,
cmakeBuildType,
result->errorMessage);
if (!result->errorMessage.isEmpty()) { if (!result->errorMessage.isEmpty()) {
qWarning() << result->errorMessage;
*result = generateFallbackData(topCmakeFile, *result = generateFallbackData(topCmakeFile,
sourceDirectory, sourceDirectory,
buildDirectory, buildDirectory,
@@ -281,7 +284,7 @@ void FileApiReader::endState(const QFileInfo &replyFi)
qWarning() << result->errorMessage; qWarning() << result->errorMessage;
} }
return result; fi.reportResult(result);
}); });
onResultReady(m_future.value(), onResultReady(m_future.value(),
this, this,
@@ -336,6 +339,28 @@ void FileApiReader::makeBackupConfiguration(bool store)
} }
void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &configurationArguments)
{
const FilePath buildDir = m_parameters.workDirectory;
QTC_ASSERT(buildDir.exists(), return );
const FilePath settingsFile = buildDir.pathAppended("qtcsettings.cmake");
QByteArray contents;
contents.append("# This file is managed by Qt Creator, do not edit!\n\n");
contents.append(
transform(CMakeConfigItem::itemsFromArguments(configurationArguments),
[](const CMakeConfigItem &item) {
return item.toCMakeSetLine(nullptr);
})
.join('\n')
.toUtf8());
QFile file(settingsFile.toString());
QTC_ASSERT(file.open(QFile::WriteOnly | QFile::Truncate), return );
file.write(contents);
}
void FileApiReader::startCMakeState(const QStringList &configurationArguments) void FileApiReader::startCMakeState(const QStringList &configurationArguments)
{ {
qCDebug(cmakeFileApiMode) << "FileApiReader: START CMAKE STATE."; qCDebug(cmakeFileApiMode) << "FileApiReader: START CMAKE STATE.";
@@ -347,6 +372,7 @@ void FileApiReader::startCMakeState(const QStringList &configurationArguments)
qCDebug(cmakeFileApiMode) << ">>>>>> Running cmake with arguments:" << configurationArguments; qCDebug(cmakeFileApiMode) << ">>>>>> Running cmake with arguments:" << configurationArguments;
makeBackupConfiguration(true); makeBackupConfiguration(true);
writeConfigurationIntoBuildDirectory(configurationArguments);
m_cmakeProcess->run(m_parameters, configurationArguments); m_cmakeProcess->run(m_parameters, configurationArguments);
} }

View File

@@ -93,6 +93,8 @@ private:
void replyDirectoryHasChanged(const QString &directory) const; void replyDirectoryHasChanged(const QString &directory) const;
void makeBackupConfiguration(bool store); void makeBackupConfiguration(bool store);
void writeConfigurationIntoBuildDirectory(const QStringList &configuration);
std::unique_ptr<CMakeProcess> m_cmakeProcess; std::unique_ptr<CMakeProcess> m_cmakeProcess;
// cmake data: // cmake data:

View File

@@ -86,6 +86,42 @@ bool FancyToolButton::event(QEvent *e)
return QToolButton::event(e); return QToolButton::event(e);
} }
static int findSplitPos(const QString &text, const QFontMetrics &fontMetrics, qreal availableWidth)
{
if (text.length() == 0)
return -1;
int splitPos = -1;
int lastWhiteSpace;
int firstWhiteSpace = text.length();
do {
// search backwards for ranges of whitespaces
// search first whitespace (backwards)
lastWhiteSpace = firstWhiteSpace - 1; // start before last blob (or at end of text)
while (lastWhiteSpace >= 0) {
if (text.at(lastWhiteSpace).isSpace())
break;
--lastWhiteSpace;
}
// search last whitespace (backwards)
firstWhiteSpace = lastWhiteSpace;
while (firstWhiteSpace > 0) {
if (!text.at(firstWhiteSpace - 1).isSpace())
break;
--firstWhiteSpace;
}
// if the text after the whitespace range fits into the available width, that's a great
// position for splitting, but look if we can fit more
if (firstWhiteSpace != -1) {
if (fontMetrics.horizontalAdvance(text.mid(lastWhiteSpace + 1)) <= availableWidth)
splitPos = lastWhiteSpace + 1;
else
break;
}
} while (firstWhiteSpace > 0
&& fontMetrics.horizontalAdvance(text.left(firstWhiteSpace)) > availableWidth);
return splitPos;
}
static QVector<QString> splitInTwoLines(const QString &text, static QVector<QString> splitInTwoLines(const QString &text,
const QFontMetrics &fontMetrics, const QFontMetrics &fontMetrics,
qreal availableWidth) qreal availableWidth)
@@ -95,21 +131,7 @@ static QVector<QString> splitInTwoLines(const QString &text,
// to put them in the second line. First line is drawn with ellipsis, // to put them in the second line. First line is drawn with ellipsis,
// second line gets ellipsis if it couldn't split off full words. // second line gets ellipsis if it couldn't split off full words.
QVector<QString> splitLines(2); QVector<QString> splitLines(2);
const QRegularExpression rx(QLatin1String("\\s+")); const int splitPos = findSplitPos(text, fontMetrics, availableWidth);
int splitPos = -1;
int nextSplitPos = text.length();
do {
int offset = nextSplitPos - text.length() - 1;
nextSplitPos = text.lastIndexOf(rx, offset);
if (nextSplitPos != -1) {
const QRegularExpressionMatch match = rx.match(text, offset);
int splitCandidate = nextSplitPos + match.capturedLength();
if (fontMetrics.horizontalAdvance(text.mid(splitCandidate)) <= availableWidth)
splitPos = splitCandidate;
else
break;
}
} while (nextSplitPos > 0 && fontMetrics.horizontalAdvance(text.left(nextSplitPos)) > availableWidth);
// check if we could split at white space at all // check if we could split at white space at all
if (splitPos < 0) { if (splitPos < 0) {
splitLines[0] = fontMetrics.elidedText(text, Qt::ElideRight, int(availableWidth)); splitLines[0] = fontMetrics.elidedText(text, Qt::ElideRight, int(availableWidth));

View File

@@ -436,6 +436,9 @@ QList<Declaration *> SymbolFinder::findMatchingDeclaration(const LookupContext &
Function *functionType) Function *functionType)
{ {
QList<Declaration *> result; QList<Declaration *> result;
if (!functionType)
return result;
QList<Declaration *> nameMatch, argumentCountMatch, typeMatch; QList<Declaration *> nameMatch, argumentCountMatch, typeMatch;
findMatchingDeclaration(context, functionType, &typeMatch, &argumentCountMatch, &nameMatch); findMatchingDeclaration(context, functionType, &typeMatch, &argumentCountMatch, &nameMatch);
result.append(typeMatch); result.append(typeMatch);

View File

@@ -68,7 +68,6 @@ void XcodeProbe::detectDeveloperPaths()
Utils::SynchronousProcess selectedXcode; Utils::SynchronousProcess selectedXcode;
selectedXcode.setTimeoutS(5); selectedXcode.setTimeoutS(5);
selectedXcode.setCommand({"/usr/bin/xcode-select", {"--print-path"}}); selectedXcode.setCommand({"/usr/bin/xcode-select", {"--print-path"}});
selectedXcode.setProcessUserEventWhileRunning();
selectedXcode.runBlocking(); selectedXcode.runBlocking();
if (selectedXcode.result() != QtcProcess::FinishedWithSuccess) if (selectedXcode.result() != QtcProcess::FinishedWithSuccess)
qCWarning(probeLog) qCWarning(probeLog)

View File

@@ -24,14 +24,18 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.0 import QtQuick 2.0
import QtGraphicalEffects 1.0
Item { Item {
id: root id: root
property real desaturation: 1.0 property real desaturation: 1.0
layer.enabled: true
layer.effect: Desaturate { Rectangle {
desaturation: root.desaturation z: 10
anchors.fill: parent
color: "#2d2e30"
anchors.margins: -16
opacity: root.desaturation * 0.6
} }
} }

View File

@@ -273,7 +273,7 @@ void TextEditorActionHandlerPrivate::createActions()
QKeySequence(tr("Ctrl+Shift+V")), G_EDIT_COPYPASTE, editMenu); QKeySequence(tr("Ctrl+Shift+V")), G_EDIT_COPYPASTE, editMenu);
m_modifyingActions << registerAction(NO_FORMAT_PASTE, m_modifyingActions << registerAction(NO_FORMAT_PASTE,
[] (TextEditorWidget *w) { w->pasteWithoutFormat(); }, false, tr("Paste Without Formatting"), [] (TextEditorWidget *w) { w->pasteWithoutFormat(); }, false, tr("Paste Without Formatting"),
QKeySequence(Core::useMacShortcuts ? tr("Cmd+Opt+Shift+V") : QString()), G_EDIT_COPYPASTE, editMenu); QKeySequence(Core::useMacShortcuts ? tr("Ctrl+Alt+Shift+V") : QString()), G_EDIT_COPYPASTE, editMenu);
// register "Edit -> Advanced" Menu Actions // register "Edit -> Advanced" Menu Actions
Core::ActionContainer *advancedEditMenu = Core::ActionManager::actionContainer(M_EDIT_ADVANCED); Core::ActionContainer *advancedEditMenu = Core::ActionManager::actionContainer(M_EDIT_ADVANCED);