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

This commit is contained in:
Eike Ziller
2018-03-16 10:29:37 +00:00
committed by The Qt Project
60 changed files with 2532 additions and 1337 deletions

21
dist/changes-4.6.0.md vendored
View File

@@ -24,8 +24,18 @@ General
Editing
* Added option to display annotations between lines (QTCREATORBUG-19181)
* Added shortcut setting for jumping to document start and end
* Fixed that editor could jump to end of file when editing in a different split
(QTCREATORBUG-19550)
* Fixed order of items in list of recent documents when documents are suspended
(QTCREATORBUG-19758)
* Fixed crash in generic highlighter (QTCREATORBUG-19916)
* Fixed issue with snippet variables on Gnome (QTCREATORBUG-19571)
* Fixed tool tips in binary editor (QTCREATORBUG-17573)
Help
* Improved startup performance
All Projects
@@ -54,12 +64,17 @@ QML Support
Debugging
* Split `Expressions` view from `Locals` view (QTCREATORBUG-19167)
* LLDB
* Fixed attaching to core file (QTCREATORBUG-18722)
* Fixed issue when killing LLDB from the outside (QTCREATORBUG-18723)
Qt Quick Designer
* Added font and text properties from Qt 5.10
* Fixed that items blurred when zooming in
* Fixed crash when changing control focus policy (QTCREATORBUG-19563)
* Fixed assert in backend process with Qt 5.9.4 & 5.10.1 and later
(QTCREATORBUG-19729)
Version Control Systems
@@ -73,15 +88,18 @@ Version Control Systems
Diff Viewer
* Added folding for files and chunks
* Fixed issue with repeated stage and unstage operation
Test Integration
* Added grouping of test cases (QTCREATORBUG-17979)
* Fixed handling of `qCritical` output (QTCREATORBUG-19795)
* Google Test
* Fixed detection of crashed tests (QTCREATORBUG-19565)
Model Editor
* Removed experimental state
* Added support for text alignment
* Added support for multi-line object names
* Added support for dragging items onto model editor from more panes
@@ -89,6 +107,8 @@ Model Editor
* Added `Flat` visual role
* Added `Add Related Elements` to diagram context menu
* Added wizard for scratch models
* Moved export actions to `File` menu
* Moved zoom actions to editor tool bar
* Fixed issue with selecting items (QTCREATORBUG-18368)
Platform Specific
@@ -98,6 +118,7 @@ Windows
* Added support for the [heob](https://github.com/ssbssa/heob/releases)
memory analyzer
* Fixed detection of CDB in non-default installation roots
* Fixed issue with setting `PATH` versus `Path` environment variable
Android

File diff suppressed because it is too large Load Diff

View File

@@ -155,14 +155,20 @@ Item {
property int minimumWidth: {
// max(width of longest label * 2, minimumInnerWidth)
var result = minimumInnerWidth;
for (var i = 0; i < children.length; i += 2)
for (var i = 0; i < children.length; ++i) {
if (children[i].isLabel)
result = Math.max(children[i].implicitWidth * 2 + innerMargin, result);
}
return result + 2 * outerMargin;
}
property int labelWidth: (minimumWidth - innerMargin) / 2 - outerMargin
property int valueWidth: dragHandle.x - labelWidth - innerMargin - outerMargin
onMinimumWidthChanged: {
if (dragHandle.x < minimumWidth)
dragHandle.x = minimumWidth;
if (dragHandle.x < minimumWidth - outerMargin)
dragHandle.x = minimumWidth - outerMargin;
}
Repeater {
@@ -171,8 +177,7 @@ Item {
property bool isLabel: index % 2 === 0
font.bold: isLabel
elide: Text.ElideRight
width: (text === "" || isLabel)
? implicitWidth : (dragHandle.x - col.minimumWidth / 2 - innerMargin)
width: isLabel ? col.labelWidth : col.valueWidth
text: isLabel ? (modelData + ":") : modelData
color: contentTextColor
}
@@ -213,7 +218,7 @@ Item {
MouseArea {
anchors.fill: parent
drag.target: parent
drag.minimumX: col.minimumWidth
drag.minimumX: col.minimumWidth - outerMargin
drag.axis: Drag.XAxis
cursorShape: Qt.SizeHorCursor
}

View File

@@ -28,7 +28,8 @@ import QtQuick 2.1
TimelineText {
property bool isLabel: false
property int valueWidth: 170
property int labelWidth: implicitWidth
font.bold: isLabel
elide: Text.ElideRight
width: text === "" ? 0 : (isLabel ? implicitWidth : valueWidth)
width: text === "" ? 0 : (isLabel ? labelWidth : valueWidth)
}

View File

@@ -173,27 +173,35 @@ Item {
//details
Grid {
property int outerMargin: 10
property int minimumWidth: 150
property int labelWidth: (minimumWidth - spacing) / 2 - outerMargin
property int valueWidth: dragHandle.x - labelWidth - spacing - outerMargin
id: col
x: 10
x: outerMargin
y: 5
spacing: 5
columns: 2
property int minimumWidth: 150
onChildrenChanged: {
// max(width of longest label * 2, 150)
var result = 150;
for (var i = 0; i < children.length; i += 2)
for (var i = 0; i < children.length; ++i) {
if (children[i].isLabel)
result = Math.max(children[i].implicitWidth * 2 + spacing, result);
minimumWidth = result + 20;
if (dragHandle.x < minimumWidth)
dragHandle.x = minimumWidth;
}
minimumWidth = result + 2 * outerMargin;
if (dragHandle.x < minimumWidth - outerMargin)
dragHandle.x = minimumWidth - outerMargin;
}
Repeater {
model: eventInfo.ready ? eventInfo : 0
Detail {
valueWidth: (dragHandle.x - col.minimumWidth / 2 - col.spacing)
labelWidth: col.labelWidth
valueWidth: col.valueWidth
isLabel: index % 2 === 0
text: (content === undefined) ? "" : (isLabel ? (content + ":") : content)
}
@@ -285,7 +293,7 @@ Item {
MouseArea {
anchors.fill: parent
drag.target: parent
drag.minimumX: col.minimumWidth
drag.minimumX: col.minimumWidth - col.outerMargin
drag.axis: Drag.XAxis
cursorShape: Qt.SizeHorCursor
}

View File

@@ -137,25 +137,34 @@ bool AndroidDeployQtStep::init(QList<const BuildStep *> &earlierSteps)
m_avdName = info.avdname;
m_serialNumber = info.serialNumber;
m_appProcessBinaries.clear();
m_libdir = QLatin1String("lib");
ProjectExplorer::BuildConfiguration *bc = target()->activeBuildConfiguration();
m_filesToPull.clear();
QString buildDir = bc ? bc->buildDirectory().toString() : QString();
if (bc && !buildDir.endsWith("/")) {
buildDir += "/";
}
QString linkerName("linker");
QString libDirName("lib");
if (info.cpuAbi.contains(QLatin1String("arm64-v8a")) ||
info.cpuAbi.contains(QLatin1String("x86_64"))) {
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
if (tc && tc->targetAbi().wordWidth() == 64) {
m_appProcessBinaries << QLatin1String("/system/bin/app_process64");
m_libdir += QLatin1String("64");
m_filesToPull["/system/bin/app_process64"] = buildDir + "app_process";
libDirName = "lib64";
linkerName = "linker64";
} else {
m_appProcessBinaries << QLatin1String("/system/bin/app_process32");
m_filesToPull["/system/bin/app_process32"] = buildDir + "app_process";
}
} else {
m_appProcessBinaries << QLatin1String("/system/bin/app_process32")
<< QLatin1String("/system/bin/app_process");
}
m_filesToPull["/system/bin/" + linkerName] = buildDir + linkerName;
m_filesToPull["/system/" + libDirName + "/libc.so"] = buildDir + "libc.so";
AndroidManager::setDeviceSerialNumber(target(), m_serialNumber);
ProjectExplorer::BuildConfiguration *bc = target()->activeBuildConfiguration();
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (!version)
@@ -176,7 +185,8 @@ bool AndroidDeployQtStep::init(QList<const BuildStep *> &earlierSteps)
}
m_command = tmp.toString();
m_workingDirectory = bc->buildDirectory().appendPath(QLatin1String(Constants::ANDROID_BUILDDIRECTORY)).toString();
m_workingDirectory = bc ? bc->buildDirectory().appendPath(QLatin1String(Constants::ANDROID_BUILDDIRECTORY)).toString()
: QString();
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--verbose"));
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--output"));
@@ -213,8 +223,6 @@ bool AndroidDeployQtStep::init(QList<const BuildStep *> &earlierSteps)
}
m_environment = bc ? bc->environment() : Utils::Environment();
m_buildDirectory = bc ? bc->buildDirectory().toString() : QString();
m_adbPath = AndroidConfigurations::currentConfig().adbToolPath().toString();
AndroidAvdManager avdManager;
@@ -394,30 +402,17 @@ void AndroidDeployQtStep::run(QFutureInterface<bool> &fi)
}
emit addOutput(tr("Pulling files necessary for debugging."), OutputFormat::NormalMessage);
QString localAppProcessFile = QString::fromLatin1("%1/app_process").arg(m_buildDirectory);
QFile::remove(localAppProcessFile);
foreach (const QString &remoteAppProcessFile, m_appProcessBinaries) {
for (auto itr = m_filesToPull.constBegin(); itr != m_filesToPull.constEnd(); ++itr) {
QFile::remove(itr.value());
runCommand(m_adbPath,
AndroidDeviceInfo::adbSelector(m_serialNumber)
<< QLatin1String("pull") << remoteAppProcessFile
<< localAppProcessFile);
if (QFileInfo::exists(localAppProcessFile))
break;
}
if (!QFileInfo::exists(localAppProcessFile)) {
returnValue = Failure;
<< "pull" << itr.key() << itr.value());
if (!QFileInfo::exists(itr.value())) {
emit addOutput(tr("Package deploy: Failed to pull \"%1\" to \"%2\".")
.arg(m_appProcessBinaries.join(QLatin1String("\", \"")))
.arg(localAppProcessFile), OutputFormat::ErrorMessage);
.arg(itr.key())
.arg(itr.value()), OutputFormat::ErrorMessage);
}
}
runCommand(m_adbPath,
AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("pull")
<< QLatin1String("/system/") + m_libdir + QLatin1String("/libc.so")
<< QString::fromLatin1("%1/libc.so").arg(m_buildDirectory));
reportRunResult(fi, returnValue == NoError);
}

View File

@@ -113,11 +113,10 @@ private:
Utils::FileName m_manifestName;
QString m_serialNumber;
QString m_buildDirectory;
QString m_avdName;
QString m_apkPath;
QMap<QString, QString> m_filesToPull;
QStringList m_appProcessBinaries;
QString m_libdir;
QString m_targetArch;
bool m_uninstallPreviousPackage = false;

View File

@@ -548,18 +548,21 @@ QRect BinEditorWidget::cursorRect() const
return QRect(x, y, w, m_lineHeight);
}
int BinEditorWidget::posAt(const QPoint &pos) const
Utils::optional<qint64> BinEditorWidget::posAt(const QPoint &pos, bool includeEmptyArea) const
{
const int xoffset = horizontalScrollBar()->value();
int x = xoffset + pos.x() - m_margin - m_labelWidth;
if (!includeEmptyArea && x < 0)
return Utils::nullopt;
int column = qMin(15, qMax(0,x) / m_columnWidth);
const qint64 topLine = verticalScrollBar()->value();
const qint64 line = topLine + pos.y() / m_lineHeight;
// "clear text" area
if (x > m_bytesPerLine * m_columnWidth + m_charWidth/2) {
x -= m_bytesPerLine * m_columnWidth + m_charWidth;
for (column = 0; column < 15; ++column) {
const int dataPos = line * m_bytesPerLine + column;
for (column = 0; column < 16; ++column) {
const qint64 dataPos = line * m_bytesPerLine + column;
if (dataPos < 0 || dataPos >= m_size)
break;
QChar qc(QLatin1Char(dataAt(dataPos)));
@@ -569,9 +572,14 @@ int BinEditorWidget::posAt(const QPoint &pos) const
if (x <= 0)
break;
}
if (!includeEmptyArea && x > 0) // right of the text area
return Utils::nullopt;
}
return qMin(m_size - 1, line * m_bytesPerLine + column);
const qint64 bytePos = line * m_bytesPerLine + column;
if (!includeEmptyArea && bytePos >= m_size)
return Utils::nullopt;
return qMin(m_size - 1, bytePos);
}
bool BinEditorWidget::inTextArea(const QPoint &pos) const
@@ -1041,7 +1049,7 @@ void BinEditorWidget::mousePressEvent(QMouseEvent *e)
if (e->button() != Qt::LeftButton)
return;
MoveMode moveMode = e->modifiers() & Qt::ShiftModifier ? KeepAnchor : MoveAnchor;
setCursorPosition(posAt(e->pos()), moveMode);
setCursorPosition(posAt(e->pos()).value(), moveMode);
setBlinkingCursorEnabled(true);
if (m_hexCursor == inTextArea(e->pos())) {
m_hexCursor = !m_hexCursor;
@@ -1053,7 +1061,7 @@ void BinEditorWidget::mouseMoveEvent(QMouseEvent *e)
{
if (!(e->buttons() & Qt::LeftButton))
return;
setCursorPosition(posAt(e->pos()), KeepAnchor);
setCursorPosition(posAt(e->pos()).value(), KeepAnchor);
if (m_hexCursor == inTextArea(e->pos())) {
m_hexCursor = !m_hexCursor;
updateLines();
@@ -1144,17 +1152,17 @@ bool BinEditorWidget::event(QEvent *e)
QString BinEditorWidget::toolTip(const QHelpEvent *helpEvent) const
{
int selStart = selectionStart();
int selEnd = selectionEnd();
int byteCount = std::min(8, selEnd - selStart + 1);
qint64 selStart = selectionStart();
qint64 selEnd = selectionEnd();
qint64 byteCount = std::min(8LL, selEnd - selStart + 1);
// check even position against selection line by line
bool insideSelection = false;
int startInLine = selStart;
qint64 startInLine = selStart;
do {
const int lineIndex = startInLine / m_bytesPerLine;
const int endOfLine = (lineIndex + 1) * m_bytesPerLine - 1;
const int endInLine = std::min(selEnd, endOfLine);
const qint64 lineIndex = startInLine / m_bytesPerLine;
const qint64 endOfLine = (lineIndex + 1) * m_bytesPerLine - 1;
const qint64 endInLine = std::min(selEnd, endOfLine);
const QPoint &startPoint = offsetToPos(startInLine);
const QPoint &endPoint = offsetToPos(endInLine) + QPoint(m_columnWidth, 0);
QRect selectionLineRect(startPoint, endPoint);
@@ -1167,7 +1175,10 @@ QString BinEditorWidget::toolTip(const QHelpEvent *helpEvent) const
} while (startInLine <= selEnd);
if (!insideSelection) {
// show popup for byte under cursor
selStart = posAt(helpEvent->pos());
Utils::optional<qint64> pos = posAt(helpEvent->pos(), /*includeEmptyArea*/false);
if (!pos)
return QString();
selStart = pos.value();
selEnd = selStart;
byteCount = 1;
}

View File

@@ -29,6 +29,8 @@
#include "markup.h"
#include "bineditorservice.h"
#include <utils/optional.h>
#include <QBasicTimer>
#include <QMap>
#include <QSet>
@@ -210,7 +212,7 @@ private:
QBasicTimer m_cursorBlinkTimer;
void init();
int posAt(const QPoint &pos) const;
Utils::optional<qint64> posAt(const QPoint &pos, bool includeEmptyArea = true) const;
bool inTextArea(const QPoint &pos) const;
QRect cursorRect() const;
void updateLines();

View File

@@ -123,6 +123,7 @@ bool CMakeRunConfiguration::fromMap(const QVariantMap &map)
m_executable = extraId;
if (m_title.isEmpty())
m_title = extraId;
setDefaultDisplayName(m_title);
}
return true;

View File

@@ -0,0 +1,78 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "descriptionwidgetwatcher.h"
#include "diffeditor.h"
#include "diffeditorcontroller.h"
#include <coreplugin/editormanager/documentmodel.h>
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/texteditor.h>
using namespace Core;
namespace DiffEditor {
DescriptionWidgetWatcher::DescriptionWidgetWatcher(DiffEditorController *controller)
: QObject(controller), m_document(controller->document())
{
const QList<IEditor *> editors = DocumentModel::editorsForDocument(controller->document());
for (auto *editor : editors) {
if (TextEditor::TextEditorWidget *widget = descriptionWidget(editor))
m_widgets.append(widget);
}
connect(EditorManager::instance(), &EditorManager::editorOpened,
[this](IEditor *editor) {
if (TextEditor::TextEditorWidget *widget = descriptionWidget(editor)) {
m_widgets.append(widget);
emit descriptionWidgetAdded(widget);
}
});
connect(EditorManager::instance(), &EditorManager::editorAboutToClose,
[this](IEditor *editor) {
if (TextEditor::TextEditorWidget *widget = descriptionWidget(editor)) {
emit descriptionWidgetRemoved(widget);
m_widgets.removeAll(widget);
}
});
}
QList<TextEditor::TextEditorWidget *> DescriptionWidgetWatcher::descriptionWidgets() const
{
return m_widgets;
}
TextEditor::TextEditorWidget *DescriptionWidgetWatcher::descriptionWidget(Core::IEditor *editor) const
{
if (Internal::DiffEditor *diffEditor = qobject_cast<Internal::DiffEditor *>(editor)) {
if (diffEditor->document() == m_document)
return diffEditor->descriptionWidget();
}
return nullptr;
}
} // namespace DiffEditor

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "diffeditor_global.h"
#include <QObject>
namespace Core {
class IDocument;
class IEditor;
}
namespace TextEditor { class TextEditorWidget; }
namespace DiffEditor {
class DiffEditorController;
class DIFFEDITOR_EXPORT DescriptionWidgetWatcher : public QObject
{
Q_OBJECT
public:
explicit DescriptionWidgetWatcher(DiffEditorController *controller);
QList<TextEditor::TextEditorWidget *> descriptionWidgets() const;
signals:
void descriptionWidgetAdded(TextEditor::TextEditorWidget *editor);
void descriptionWidgetRemoved(TextEditor::TextEditorWidget *editor);
private:
TextEditor::TextEditorWidget *descriptionWidget(Core::IEditor *editor) const;
QList<TextEditor::TextEditorWidget *> m_widgets;
Core::IDocument *m_document = nullptr;
};
} // namespace DiffEditor

View File

@@ -81,22 +81,11 @@ public:
virtual QSize sizeHint() const override;
signals:
void requestBranchList();
protected:
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void setDisplaySettings(const DisplaySettings &ds) override;
void setMarginSettings(const MarginSettings &ms) override;
bool findContentsUnderCursor(const QTextCursor &cursor);
void highlightCurrentContents();
void handleCurrentContents();
private:
QTextCursor m_currentCursor;
Core::IContext *m_context;
};
@@ -153,68 +142,6 @@ void DescriptionEditorWidget::setMarginSettings(const MarginSettings &ms)
TextEditorWidget::setMarginSettings(MarginSettings());
}
void DescriptionEditorWidget::mouseMoveEvent(QMouseEvent *e)
{
if (e->buttons()) {
TextEditorWidget::mouseMoveEvent(e);
return;
}
Qt::CursorShape cursorShape;
const QTextCursor cursor = cursorForPosition(e->pos());
if (findContentsUnderCursor(cursor)) {
highlightCurrentContents();
cursorShape = Qt::PointingHandCursor;
} else {
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
cursorShape = Qt::IBeamCursor;
}
TextEditorWidget::mouseMoveEvent(e);
viewport()->setCursor(cursorShape);
}
void DescriptionEditorWidget::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton && !(e->modifiers() & Qt::ShiftModifier)) {
const QTextCursor cursor = cursorForPosition(e->pos());
if (findContentsUnderCursor(cursor)) {
handleCurrentContents();
e->accept();
return;
}
}
TextEditorWidget::mouseReleaseEvent(e);
}
bool DescriptionEditorWidget::findContentsUnderCursor(const QTextCursor &cursor)
{
m_currentCursor = cursor;
return cursor.block().text() == Constants::EXPAND_BRANCHES;
}
void DescriptionEditorWidget::highlightCurrentContents()
{
QTextEdit::ExtraSelection sel;
sel.cursor = m_currentCursor;
sel.cursor.select(QTextCursor::LineUnderCursor);
sel.format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
const QColor textColor = TextEditorSettings::fontSettings().formatFor(C_TEXT).foreground();
sel.format.setUnderlineColor(textColor.isValid() ? textColor : palette().color(QPalette::Foreground));
setExtraSelections(TextEditorWidget::OtherSelection,
QList<QTextEdit::ExtraSelection>() << sel);
}
void DescriptionEditorWidget::handleCurrentContents()
{
m_currentCursor.select(QTextCursor::LineUnderCursor);
m_currentCursor.removeSelectedText();
m_currentCursor.insertText("Branches: Expanding...");
emit requestBranchList();
}
///////////////////////////////// DiffEditor //////////////////////////////////
DiffEditor::DiffEditor()
@@ -296,8 +223,6 @@ void DiffEditor::setDocument(QSharedPointer<DiffEditorDocument> doc)
m_document = doc;
connect(m_descriptionWidget, &DescriptionEditorWidget::requestBranchList,
m_document.data(), &DiffEditorDocument::requestMoreInformation);
connect(m_document.data(), &DiffEditorDocument::documentChanged,
this, &DiffEditor::documentHasChanged);
connect(m_document.data(), &DiffEditorDocument::descriptionChanged,

View File

@@ -1,7 +1,9 @@
DEFINES += DIFFEDITOR_LIBRARY
include(../../qtcreatorplugin.pri)
HEADERS += diffeditor_global.h \
HEADERS += \
descriptionwidgetwatcher.h \
diffeditor_global.h \
diffeditor.h \
diffeditorconstants.h \
diffeditorcontroller.h \
@@ -17,7 +19,9 @@ HEADERS += diffeditor_global.h \
unifieddiffeditorwidget.h \
diffeditoricons.h
SOURCES += diffeditor.cpp \
SOURCES += \
descriptionwidgetwatcher.cpp \
diffeditor.cpp \
diffeditorcontroller.cpp \
diffeditordocument.cpp \
diffeditorfactory.cpp \

View File

@@ -14,6 +14,8 @@ QtcPlugin {
]
files: [
"descriptionwidgetwatcher.cpp",
"descriptionwidgetwatcher.h",
"diffeditor.cpp",
"diffeditor.h",
"diffeditor.qrc",

View File

@@ -41,7 +41,5 @@ const char UNIFIED_VIEW_ID[] = "DiffEditor.Unified";
const char G_TOOLS_DIFF[] = "QtCreator.Group.Tools.Options";
const char EXPAND_BRANCHES[] = "Branches: <Expand>";
} // namespace Constants
} // namespace DiffEditor

View File

@@ -65,12 +65,6 @@ bool DiffEditorController::ignoreWhitespace() const
return m_document->ignoreWhitespace();
}
QString DiffEditorController::revisionFromDescription() const
{
// TODO: This is specific for git and does not belong here at all!
return m_document->description().mid(7, 12);
}
QString DiffEditorController::makePatch(int fileIndex, int chunkIndex,
PatchOptions options) const
{
@@ -105,18 +99,9 @@ void DiffEditorController::setDescription(const QString &description)
m_document->setDescription(description);
}
void DiffEditorController::branchesReceived(const QString &branches)
QString DiffEditorController::description() const
{
QString tmp = m_document->description();
tmp.replace(Constants::EXPAND_BRANCHES, branches);
m_document->setDescription(tmp);
}
void DiffEditorController::requestMoreInformation()
{
const QString rev = revisionFromDescription();
if (!rev.isEmpty())
emit requestInformationForCommit(rev);
return m_document->description();
}
/**

View File

@@ -51,8 +51,6 @@ public:
int contextLineCount() const;
bool ignoreWhitespace() const;
QString revisionFromDescription() const;
enum PatchOption {
NoOption = 0,
Revert = 1,
@@ -65,13 +63,12 @@ public:
const QString &displayName);
static DiffEditorController *controller(Core::IDocument *document);
void branchesReceived(const QString &branches);
void requestChunkActions(QMenu *menu, int fileIndex, int chunkIndex);
bool chunkExists(int fileIndex, int chunkIndex) const;
Core::IDocument *document() const;
signals:
void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex);
void requestInformationForCommit(const QString &revision);
protected:
// reloadFinished() should be called
@@ -84,14 +81,11 @@ protected:
const QString &baseDirectory = QString(),
const QString &startupFile = QString());
void setDescription(const QString &description);
QString description() const;
void forceContextLineCount(int lines);
Core::IDocument *document() const;
private:
void requestMoreInformation();
Internal::DiffEditorDocument *const m_document;
bool m_isReloading = false;
friend class Internal::DiffEditorDocument;

View File

@@ -69,11 +69,6 @@ void DiffEditorDocument::setController(DiffEditorController *controller)
if (m_controller)
m_controller->deleteLater();
m_controller = controller;
if (m_controller) {
connect(this, &DiffEditorDocument::requestMoreInformation,
m_controller, &DiffEditorController::requestMoreInformation);
}
}
DiffEditorController *DiffEditorDocument::controller() const

View File

@@ -90,7 +90,6 @@ signals:
void temporaryStateChanged();
void documentChanged();
void descriptionChanged();
void requestMoreInformation();
private:
void beginReload();

View File

@@ -62,9 +62,14 @@
#include <vcsbase/vcscommand.h>
#include <vcsbase/vcsoutputwindow.h>
#include <diffeditor/descriptionwidgetwatcher.h>
#include <diffeditor/diffeditorconstants.h>
#include <diffeditor/diffeditorcontroller.h>
#include <diffeditor/diffutils.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorsettings.h>
#include <utils/utilsicons.h>
#include <QAction>
@@ -76,8 +81,9 @@
#include <QMessageBox>
#include <QPushButton>
#include <QRegExp>
#include <QTextCodec>
#include <QTextBlock>
#include <QToolButton>
#include <QTextCodec>
const char GIT_DIRECTORY[] = ".git";
const char graphLogFormatC[] = "%h %d %an %s %ci";
@@ -112,6 +118,153 @@ const unsigned silentFlags = unsigned(VcsCommand::SuppressCommandLogging
| VcsCommand::SuppressStdErr
| VcsCommand::SuppressFailMessage);
static QString branchesDisplay(const QString &prefix, QStringList *branches, bool *first)
{
const int limit = 12;
const int count = branches->count();
int more = 0;
QString output;
if (*first)
*first = false;
else
output += QString(sizeof(BRANCHES_PREFIX) - 1, ' '); // Align
output += prefix + ": ";
// If there are more than 'limit' branches, list limit/2 (first limit/4 and last limit/4)
if (count > limit) {
const int leave = limit / 2;
more = count - leave;
branches->erase(branches->begin() + leave / 2 + 1, branches->begin() + count - leave / 2);
(*branches)[leave / 2] = "...";
}
output += branches->join(", ");
//: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'"
// in git show.
if (more > 0)
output += ' ' + GitClient::tr("and %n more", 0, more);
return output;
}
class DescriptionWidgetDecorator : public QObject
{
Q_OBJECT
public:
DescriptionWidgetDecorator(DescriptionWidgetWatcher *watcher);
bool eventFilter(QObject *watched, QEvent *event) override;
signals:
void branchListRequested();
private:
bool checkContentsUnderCursor(const QTextCursor &cursor) const;
void highlightCurrentContents(TextEditor::TextEditorWidget *textEditor,
const QTextCursor &cursor);
void handleCurrentContents(const QTextCursor &cursor);
void addWatch(TextEditor::TextEditorWidget *widget);
void removeWatch(TextEditor::TextEditorWidget *widget);
DescriptionWidgetWatcher *m_watcher;
QHash<QObject *, TextEditor::TextEditorWidget *> m_viewportToTextEditor;
};
DescriptionWidgetDecorator::DescriptionWidgetDecorator(DescriptionWidgetWatcher *watcher)
: QObject(),
m_watcher(watcher)
{
QList<TextEditor::TextEditorWidget *> widgets = m_watcher->descriptionWidgets();
for (auto *widget : widgets)
addWatch(widget);
connect(m_watcher, &DescriptionWidgetWatcher::descriptionWidgetAdded,
this, &DescriptionWidgetDecorator::addWatch);
connect(m_watcher, &DescriptionWidgetWatcher::descriptionWidgetRemoved,
this, &DescriptionWidgetDecorator::removeWatch);
}
bool DescriptionWidgetDecorator::eventFilter(QObject *watched, QEvent *event)
{
TextEditor::TextEditorWidget *textEditor = m_viewportToTextEditor.value(watched);
if (!textEditor)
return QObject::eventFilter(watched, event);
if (event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->buttons())
return QObject::eventFilter(watched, event);
Qt::CursorShape cursorShape;
const QTextCursor cursor = textEditor->cursorForPosition(mouseEvent->pos());
if (checkContentsUnderCursor(cursor)) {
highlightCurrentContents(textEditor, cursor);
cursorShape = Qt::PointingHandCursor;
} else {
textEditor->setExtraSelections(TextEditor::TextEditorWidget::OtherSelection,
QList<QTextEdit::ExtraSelection>());
cursorShape = Qt::IBeamCursor;
}
bool ret = QObject::eventFilter(watched, event);
textEditor->viewport()->setCursor(cursorShape);
return ret;
} else if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton && !(mouseEvent->modifiers() & Qt::ShiftModifier)) {
const QTextCursor cursor = textEditor->cursorForPosition(mouseEvent->pos());
if (checkContentsUnderCursor(cursor)) {
handleCurrentContents(cursor);
return true;
}
}
return QObject::eventFilter(watched, event);
}
return QObject::eventFilter(watched, event);
}
bool DescriptionWidgetDecorator::checkContentsUnderCursor(const QTextCursor &cursor) const
{
return cursor.block().text() == Constants::EXPAND_BRANCHES;
}
void DescriptionWidgetDecorator::highlightCurrentContents(
TextEditor::TextEditorWidget *textEditor, const QTextCursor &cursor)
{
QTextEdit::ExtraSelection sel;
sel.cursor = cursor;
sel.cursor.select(QTextCursor::LineUnderCursor);
sel.format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
const QColor textColor = TextEditor::TextEditorSettings::fontSettings().formatFor(TextEditor::C_TEXT).foreground();
sel.format.setUnderlineColor(textColor.isValid() ? textColor : textEditor->palette().color(QPalette::Foreground));
textEditor->setExtraSelections(TextEditor::TextEditorWidget::OtherSelection,
QList<QTextEdit::ExtraSelection>() << sel);
}
void DescriptionWidgetDecorator::handleCurrentContents(const QTextCursor &cursor)
{
QTextCursor copy = cursor;
copy.select(QTextCursor::LineUnderCursor);
copy.removeSelectedText();
copy.insertText("Branches: Expanding...");
emit branchListRequested();
}
void DescriptionWidgetDecorator::addWatch(TextEditor::TextEditorWidget *widget)
{
m_viewportToTextEditor.insert(widget->viewport(), widget);
widget->viewport()->installEventFilter(this);
}
void DescriptionWidgetDecorator::removeWatch(TextEditor::TextEditorWidget *widget)
{
widget->viewport()->removeEventFilter(this);
m_viewportToTextEditor.remove(widget->viewport());
}
///////////////////////////////
class GitDiffEditorController : public VcsBaseDiffEditorController
{
Q_OBJECT
@@ -124,13 +277,75 @@ protected:
QStringList addConfigurationArguments(const QStringList &args) const;
QStringList addHeadWhenCommandInProgress() const;
private:
void updateBranchList();
DescriptionWidgetWatcher m_watcher;
DescriptionWidgetDecorator m_decorator;
};
GitDiffEditorController::GitDiffEditorController(IDocument *document, const QString &workingDirectory) :
VcsBaseDiffEditorController(document, GitPlugin::client(), workingDirectory)
VcsBaseDiffEditorController(document, GitPlugin::client(), workingDirectory),
m_watcher(this),
m_decorator(&m_watcher)
{
connect(&m_decorator, &DescriptionWidgetDecorator::branchListRequested,
this, &GitDiffEditorController::updateBranchList);
}
void GitDiffEditorController::updateBranchList()
{
const QString revision = description().mid(7, 12);
if (revision.isEmpty())
return;
const QString workingDirectory = baseDirectory();
VcsCommand *command = GitPlugin::client()->vcsExec(
workingDirectory, {"branch", noColorOption, "-a", "--contains", revision}, nullptr,
false, 0, workingDirectory);
connect(command, &VcsCommand::stdOutText, [this](const QString &text) {
const QString remotePrefix = "remotes/";
const QString localPrefix = "<Local>";
const int prefixLength = remotePrefix.length();
QString output = BRANCHES_PREFIX;
QStringList branches;
QString previousRemote = localPrefix;
bool first = true;
for (const QString &branch : text.split('\n')) {
const QString b = branch.mid(2).trimmed();
if (b.isEmpty())
continue;
if (b.startsWith(remotePrefix)) {
const int nextSlash = b.indexOf('/', prefixLength);
if (nextSlash < 0)
continue;
const QString remote = b.mid(prefixLength, nextSlash - prefixLength);
if (remote != previousRemote) {
output += branchesDisplay(previousRemote, &branches, &first) + '\n';
branches.clear();
previousRemote = remote;
}
branches << b.mid(nextSlash + 1);
} else {
branches << b;
}
}
if (branches.isEmpty()) {
if (previousRemote == localPrefix)
output += tr("<None>");
} else {
output += branchesDisplay(previousRemote, &branches, &first);
}
const QString branchList = output.trimmed();
QString newDescription = description();
newDescription.replace(Constants::EXPAND_BRANCHES, branchList);
setDescription(newDescription);
});
}
///////////////////////////////
void GitDiffEditorController::runCommand(const QList<QStringList> &args, QTextCodec *codec)
{
VcsBaseDiffEditorController::runCommand(args, diffExecutionFlags(), codec);
@@ -679,8 +894,6 @@ void GitClient::requestReload(const QString &documentId, const QString &source,
connect(controller, &DiffEditorController::chunkActionsRequested,
this, &GitClient::chunkActionsRequested, Qt::DirectConnection);
connect(controller, &DiffEditorController::requestInformationForCommit,
this, &GitClient::branchesForCommit);
VcsBasePlugin::setSource(document, sourceCopy);
EditorManager::activateEditorForDocument(document);
@@ -1379,76 +1592,6 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const
}
}
static QString branchesDisplay(const QString &prefix, QStringList *branches, bool *first)
{
const int limit = 12;
const int count = branches->count();
int more = 0;
QString output;
if (*first)
*first = false;
else
output += QString(sizeof(BRANCHES_PREFIX) - 1, ' '); // Align
output += prefix + ": ";
// If there are more than 'limit' branches, list limit/2 (first limit/4 and last limit/4)
if (count > limit) {
const int leave = limit / 2;
more = count - leave;
branches->erase(branches->begin() + leave / 2 + 1, branches->begin() + count - leave / 2);
(*branches)[leave / 2] = "...";
}
output += branches->join(", ");
//: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'"
// in git show.
if (more > 0)
output += ' ' + GitClient::tr("and %n more", 0, more);
return output;
}
void GitClient::branchesForCommit(const QString &revision)
{
auto controller = qobject_cast<DiffEditorController *>(sender());
QString workingDirectory = controller->baseDirectory();
VcsCommand *command = vcsExec(
workingDirectory, {"branch", noColorOption, "-a", "--contains", revision}, nullptr,
false, 0, workingDirectory);
connect(command, &VcsCommand::stdOutText, controller, [controller](const QString &text) {
const QString remotePrefix = "remotes/";
const QString localPrefix = "<Local>";
const int prefixLength = remotePrefix.length();
QString output = BRANCHES_PREFIX;
QStringList branches;
QString previousRemote = localPrefix;
bool first = true;
for (const QString &branch : text.split('\n')) {
const QString b = branch.mid(2).trimmed();
if (b.isEmpty())
continue;
if (b.startsWith(remotePrefix)) {
const int nextSlash = b.indexOf('/', prefixLength);
if (nextSlash < 0)
continue;
const QString remote = b.mid(prefixLength, nextSlash - prefixLength);
if (remote != previousRemote) {
output += branchesDisplay(previousRemote, &branches, &first) + '\n';
branches.clear();
previousRemote = remote;
}
branches << b.mid(nextSlash + 1);
} else {
branches << b;
}
}
if (branches.isEmpty()) {
if (previousRemote == localPrefix)
output += tr("<None>");
} else {
output += branchesDisplay(previousRemote, &branches, &first);
}
controller->branchesReceived(output.trimmed());
});
}
bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &commit)
{
return !vcsFullySynchronousExec(
@@ -2110,7 +2253,7 @@ QString GitClient::extendedShowDescription(const QString &workingDirectory, cons
// Empty line before headers and commit message
const int emptyLine = modText.indexOf("\n\n");
if (emptyLine != -1)
modText.insert(emptyLine, QString('\n') + DiffEditor::Constants::EXPAND_BRANCHES);
modText.insert(emptyLine, QString('\n') + Constants::EXPAND_BRANCHES);
return modText;
}

View File

@@ -330,7 +330,6 @@ public:
private:
void finishSubmoduleUpdate();
void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex);
void branchesForCommit(const QString &revision);
void stage(DiffEditor::DiffEditorController *diffController,
const QString &patch, bool revert);

View File

@@ -53,5 +53,7 @@ const char C_GITEDITORID[] = "Git Editor";
const int OBSOLETE_COMMIT_AGE_IN_DAYS = 90;
const char EXPAND_BRANCHES[] = "Branches: <Expand>";
} // namespace Constants
} // namespace Git

View File

@@ -160,10 +160,13 @@ static void createTree(const QmakePriFile *pri, QmakePriFileNode *node, const Fi
QString errorMessage;
// Prefer the cumulative file if it's non-empty, based on the assumption
// that it contains more "stuff".
vfs->readFile(file.toString(), QMakeVfs::VfsCumulative, &contents, &errorMessage);
int cid = vfs->idForFileName(file.toString(), QMakeVfs::VfsCumulative);
vfs->readFile(cid, &contents, &errorMessage);
// If the cumulative evaluation botched the file too much, try the exact one.
if (contents.isEmpty())
vfs->readFile(file.toString(), QMakeVfs::VfsExact, &contents, &errorMessage);
if (contents.isEmpty()) {
int eid = vfs->idForFileName(file.toString(), QMakeVfs::VfsExact);
vfs->readFile(eid, &contents, &errorMessage);
}
auto resourceNode = new ResourceEditor::ResourceTopLevelNode(file, false, contents, vfolder);
vfolder->addNode(resourceNode);
}

View File

@@ -236,7 +236,8 @@ QmakePriFile::~QmakePriFile()
void QmakePriFile::scheduleUpdate()
{
QtSupport::ProFileCacheManager::instance()->discardFile(filePath().toString());
QtSupport::ProFileCacheManager::instance()->discardFile(
filePath().toString(), m_project->qmakeVfs());
m_qmakeProFile->scheduleUpdate(QmakeProFile::ParseLater);
}
@@ -291,11 +292,11 @@ static QStringList fileListForVar(
}
void QmakePriFile::extractSources(
QHash<const ProFile *, QmakePriFileEvalResult *> proToResult, QmakePriFileEvalResult *fallback,
QHash<int, QmakePriFileEvalResult *> proToResult, QmakePriFileEvalResult *fallback,
QVector<ProFileEvaluator::SourceFile> sourceFiles, FileType type)
{
foreach (const ProFileEvaluator::SourceFile &source, sourceFiles) {
QmakePriFileEvalResult *result = proToResult.value(source.proFile);
auto *result = proToResult.value(source.proFileId);
if (!result)
result = fallback;
result->foundFiles[type].insert(FileName::fromString(source.fileName));
@@ -303,12 +304,12 @@ void QmakePriFile::extractSources(
}
void QmakePriFile::extractInstalls(
QHash<const ProFile *, QmakePriFileEvalResult *> proToResult, QmakePriFileEvalResult *fallback,
QHash<int, QmakePriFileEvalResult *> proToResult, QmakePriFileEvalResult *fallback,
const InstallsList &installList)
{
for (const InstallsItem &item : installList.items) {
for (const ProFileEvaluator::SourceFile &source : item.files) {
auto *result = proToResult.value(source.proFile);
auto *result = proToResult.value(source.proFileId);
if (!result)
result = fallback;
result->folders.insert(FileName::fromString(source.fileName));
@@ -620,7 +621,8 @@ bool QmakePriFile::saveModifiedEditors()
return false;
// force instant reload of ourselves
QtSupport::ProFileCacheManager::instance()->discardFile(filePath().toString());
QtSupport::ProFileCacheManager::instance()->discardFile(
filePath().toString(), m_project->qmakeVfs());
QmakeProject::notifyChanged(filePath());
return true;
}
@@ -700,7 +702,7 @@ QPair<ProFile *, QStringList> QmakePriFile::readProFile(const QString &file)
QMakeVfs vfs;
QtSupport::ProMessageHandler handler;
QMakeParser parser(nullptr, &vfs, &handler);
includeFile = parser.parsedProBlock(QStringRef(&contents), file, 1);
includeFile = parser.parsedProBlock(QStringRef(&contents), 0, file, 1);
}
return qMakePair(includeFile, lines);
}
@@ -737,7 +739,7 @@ bool QmakePriFile::renameFile(const QString &oldName,
QMakeParser parser(nullptr, nullptr, nullptr);
QString contents = lines.join(QLatin1Char('\n'));
includeFile = parser.parsedProBlock(QStringRef(&contents),
filePath().toString(), 1, QMakeParser::FullGrammar);
0, filePath().toString(), 1, QMakeParser::FullGrammar);
QTC_ASSERT(includeFile, return false); // The file should still be valid after what we did.
ProWriter::addFiles(includeFile, &lines,
@@ -1293,7 +1295,7 @@ QmakeEvalResult *QmakeProFile::evaluate(const QmakeEvalInput &input)
result->includedFiles.proFile = pro;
result->includedFiles.name = input.projectFilePath;
QHash<const ProFile *, QmakePriFileEvalResult *> proToResult;
QHash<int, QmakePriFileEvalResult *> proToResult;
result->projectType
= proFileTemplateTypeToProjectType(
@@ -1331,7 +1333,7 @@ QmakeEvalResult *QmakeProFile::evaluate(const QmakeEvalInput &input)
childTree->proFile = child;
childTree->name = childName;
current->children.insert(childName, childTree);
proToResult[child] = &childTree->result;
proToResult[child->id()] = &childTree->result;
}
}
toBuild.append(current->children.values());
@@ -1367,7 +1369,7 @@ QmakeEvalResult *QmakeProFile::evaluate(const QmakeEvalInput &input)
childTree->proFile = child;
childTree->name = childName;
current->children.insert(childName, childTree);
proToResult[child] = &childTree->result;
proToResult[child->id()] = &childTree->result;
}
}
toBuild.append(current->children.values());

View File

@@ -201,11 +201,11 @@ private:
static QStringList baseVPaths(QtSupport::ProFileReader *reader, const QString &projectDir, const QString &buildDir);
static QStringList fullVPaths(const QStringList &baseVPaths, QtSupport::ProFileReader *reader, const QString &qmakeVariable, const QString &projectDir);
static void extractSources(
QHash<const ProFile *, Internal::QmakePriFileEvalResult *> proToResult,
QHash<int, Internal::QmakePriFileEvalResult *> proToResult,
Internal::QmakePriFileEvalResult *fallback,
QVector<ProFileEvaluator::SourceFile> sourceFiles, ProjectExplorer::FileType type);
static void extractInstalls(
QHash<const ProFile *, Internal::QmakePriFileEvalResult *> proToResult,
QHash<int, Internal::QmakePriFileEvalResult *> proToResult,
Internal::QmakePriFileEvalResult *fallback,
const InstallsList &installList);
static void processValues(Internal::QmakePriFileEvalResult &result);

View File

@@ -372,12 +372,14 @@ void QmakeProject::updateQmlJSCodeModel()
QString errorMessage;
foreach (const QString &rc, exactResources) {
QString contents;
if (m_qmakeVfs->readFile(rc, QMakeVfs::VfsExact, &contents, &errorMessage) == QMakeVfs::ReadOk)
int id = m_qmakeVfs->idForFileName(rc, QMakeVfs::VfsExact);
if (m_qmakeVfs->readFile(id, &contents, &errorMessage) == QMakeVfs::ReadOk)
projectInfo.resourceFileContents[rc] = contents;
}
foreach (const QString &rc, cumulativeResources) {
QString contents;
if (m_qmakeVfs->readFile(rc, QMakeVfs::VfsCumulative, &contents, &errorMessage) == QMakeVfs::ReadOk)
int id = m_qmakeVfs->idForFileName(rc, QMakeVfs::VfsCumulative);
if (m_qmakeVfs->readFile(id, &contents, &errorMessage) == QMakeVfs::ReadOk)
projectInfo.resourceFileContents[rc] = contents;
}
if (!hasQmlLib) {
@@ -734,7 +736,7 @@ void QmakeProject::destroyProFileReader(QtSupport::ProFileReader *reader)
QString dir = projectFilePath().toString();
if (!dir.endsWith(QLatin1Char('/')))
dir += QLatin1Char('/');
QtSupport::ProFileCacheManager::instance()->discardFiles(dir);
QtSupport::ProFileCacheManager::instance()->discardFiles(dir, qmakeVfs());
QtSupport::ProFileCacheManager::instance()->decRefCount();
m_qmakeGlobals.reset();
@@ -842,7 +844,8 @@ void QmakeProject::setAllBuildConfigurationsEnabled(bool enabled)
static void notifyChangedHelper(const FileName &fileName, QmakeProFile *file)
{
if (file->filePath() == fileName) {
QtSupport::ProFileCacheManager::instance()->discardFile(fileName.toString());
QtSupport::ProFileCacheManager::instance()->discardFile(
fileName.toString(), file->project()->qmakeVfs());
file->scheduleUpdate(QmakeProFile::ParseNow);
}

View File

@@ -36,6 +36,8 @@
#include <qmljseditor/qmljseditorconstants.h>
#include <qmljstools/qmljstoolsconstants.h>
#include <utils/qtcassert.h>
#include <QLineEdit>
#include <QTextStream>
#include <QMessageBox>
@@ -62,12 +64,14 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
m_ui.designerShowDebuggerCheckBox->setChecked(true);
}
);
m_ui.resetFallbackPuppetPathButton->hide();
connect(m_ui.resetFallbackPuppetPathButton, &QPushButton::clicked, [=]() {
m_ui.fallbackPuppetPathLineEdit->setPath(
PuppetCreator::defaultPuppetFallbackDirectory());
}
);
m_ui.fallbackPuppetPathLineEdit->setPath(PuppetCreator::defaultPuppetFallbackDirectory());
m_ui.fallbackPuppetPathLineEdit->lineEdit()->setPlaceholderText(PuppetCreator::defaultPuppetFallbackDirectory());
connect(m_ui.resetQmlPuppetBuildPathButton, &QPushButton::clicked, [=]() {
m_ui.puppetBuildPathLineEdit->setPath(
PuppetCreator::defaultPuppetToplevelBuildDirectory());
@@ -129,10 +133,16 @@ DesignerSettings SettingsPageWidget::settings() const
settings.insert(DesignerSettingsKey::DEBUG_PUPPET,
m_ui.debugPuppetComboBox->currentText());
if (!m_ui.fallbackPuppetPathLineEdit->path().isEmpty() &&
m_ui.fallbackPuppetPathLineEdit->path() != PuppetCreator::defaultPuppetFallbackDirectory()) {
QString newFallbackPuppetPath = m_ui.fallbackPuppetPathLineEdit->path();
QTC_CHECK(PuppetCreator::defaultPuppetFallbackDirectory() ==
m_ui.fallbackPuppetPathLineEdit->lineEdit()->placeholderText());
if (newFallbackPuppetPath.isEmpty())
newFallbackPuppetPath = m_ui.fallbackPuppetPathLineEdit->lineEdit()->placeholderText();
QString oldFallbackPuppetPath = settings.value(DesignerSettingsKey::PUPPET_FALLBACK_DIRECTORY,
PuppetCreator::defaultPuppetFallbackDirectory()).toString();
if (oldFallbackPuppetPath != newFallbackPuppetPath) {
settings.insert(DesignerSettingsKey::PUPPET_FALLBACK_DIRECTORY,
m_ui.fallbackPuppetPathLineEdit->path());
newFallbackPuppetPath);
}
if (!m_ui.puppetBuildPathLineEdit->path().isEmpty() &&

View File

@@ -312,8 +312,7 @@ void ExamplesListModel::parseExamples(QXmlStreamReader *reader,
item.projectPath = attributes.value(QLatin1String("projectPath")).toString();
item.hasSourceCode = !item.projectPath.isEmpty();
item.projectPath = relativeOrInstallPath(item.projectPath, projectsOffset, examplesInstallPath);
item.imageUrl = Utils::StyleHelper::dpiSpecificImageFile(
attributes.value(QLatin1String("imageUrl")).toString());
item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString();
QPixmapCache::remove(item.imageUrl);
item.docUrl = attributes.value(QLatin1String("docUrl")).toString();
item.isHighlighted = attributes.value(QLatin1String("isHighlighted")).toString() == QLatin1String("true");
@@ -412,7 +411,8 @@ void ExamplesListModel::parseTutorials(QXmlStreamReader *reader, const QString &
item.hasSourceCode = !item.projectPath.isEmpty();
item.projectPath.prepend(slash);
item.projectPath.prepend(projectsOffset);
item.imageUrl = attributes.value(QLatin1String("imageUrl")).toString();
item.imageUrl = Utils::StyleHelper::dpiSpecificImageFile(
attributes.value(QLatin1String("imageUrl")).toString());
QPixmapCache::remove(item.imageUrl);
item.docUrl = attributes.value(QLatin1String("docUrl")).toString();
item.isVideo = attributes.value(QLatin1String("isVideo")).toString() == QLatin1String("true");

View File

@@ -413,6 +413,7 @@ public:
QRect pixmapRect = inner;
if (!pm.isNull()) {
painter->setPen(foregroundColor2);
if (!m_showExamples)
pixmapRect = inner.adjusted(6, 20, -6, -15);
QPoint pixmapPos = pixmapRect.center();
pixmapPos.rx() -= pm.width() / pm.devicePixelRatio() / 2;
@@ -533,6 +534,8 @@ public:
return QAbstractItemDelegate::editorEvent(ev, model, option, idx);
}
void setShowExamples(bool showExamples) { m_showExamples = showExamples; goon(); }
signals:
void tagClicked(const QString &tag);
@@ -547,6 +550,7 @@ private:
mutable QRect m_currentArea;
mutable QPointer<QAbstractItemView> m_currentWidget;
mutable QVector<QPair<QString, QRect>> m_currentTagRects;
bool m_showExamples = true;
};
class ExamplesPageWidget : public QWidget
@@ -555,6 +559,7 @@ public:
ExamplesPageWidget(bool isExamples)
: m_isExamples(isExamples)
{
m_exampleDelegate.setShowExamples(isExamples);
const int sideMargin = 27;
static ExamplesListModel *s_examplesModel = new ExamplesListModel(this);
m_examplesModel = s_examplesModel;

View File

@@ -166,16 +166,17 @@ void ProFileCacheManager::clear()
// loop is concerned. Use a shared pointer once this is not true anymore.
delete m_cache;
m_cache = 0;
QMakeVfs::clearIds();
}
void ProFileCacheManager::discardFiles(const QString &prefix)
void ProFileCacheManager::discardFiles(const QString &prefix, QMakeVfs *vfs)
{
if (m_cache)
m_cache->discardFiles(prefix);
m_cache->discardFiles(prefix, vfs);
}
void ProFileCacheManager::discardFile(const QString &fileName)
void ProFileCacheManager::discardFile(const QString &fileName, QMakeVfs *vfs)
{
if (m_cache)
m_cache->discardFile(fileName);
m_cache->discardFile(fileName, vfs);
}

View File

@@ -93,8 +93,8 @@ class QTSUPPORT_EXPORT ProFileCacheManager : public QObject
public:
static ProFileCacheManager *instance() { return s_instance; }
ProFileCache *cache();
void discardFiles(const QString &prefix);
void discardFile(const QString &fileName);
void discardFiles(const QString &prefix, QMakeVfs *vfs);
void discardFile(const QString &fileName, QMakeVfs *vfs);
void incRefCount();
void decRefCount();

View File

@@ -66,6 +66,10 @@
<description><![CDATA[Using Qt Creator tutorials and examples to develop Qt applications.]]></description>
<tags>qt creator,video</tags>
</tutorial>
<tutorial imageUrl=":qtsupport/images/icons/videotutorialicon.png" difficulty="" projectPath="" name="Online: Qt Creator - Using Qt Quick Designer" isVideo="true" videoUrl="https://www.youtube.com/watch?v=0Po3tE9yUcU" videoLength="7:36">
<description><![CDATA[Using Qt Quick Designer to develop Qt Quick applications.]]></description>
<tags>qt creator,qt quick,video</tags>
</tutorial>
<tutorial imageUrl=":qtsupport/images/icons/qteventicon.png" difficulty="" projectPath="" name="Talk: Qt Creator - Getting Started" isVideo="true" videoUrl="https://www.youtube.com/watch?v=nGFmjOiT22Y" videoLength="50:36">
<description><![CDATA[Getting started with using Qt Creator for cross-platform development.]]></description>

View File

@@ -35,8 +35,13 @@
# include <sys/types.h>
# include <sys/stat.h>
# include <unistd.h>
# include <utime.h>
# include <fcntl.h>
# include <errno.h>
#endif
#define fL1S(s) QString::fromLatin1(s)
QT_BEGIN_NAMESPACE
using namespace QMakeInternal;
@@ -59,21 +64,22 @@ IoUtils::FileType IoUtils::fileType(const QString &fileName)
bool IoUtils::isRelativePath(const QString &path)
{
if (path.startsWith(QLatin1Char('/')))
return false;
#ifdef QMAKE_BUILTIN_PRFS
if (path.startsWith(QLatin1String(":/")))
return false;
#endif
#ifdef Q_OS_WIN
if (path.startsWith(QLatin1Char('\\')))
return false;
// Unlike QFileInfo, this won't accept a relative path with a drive letter.
// Such paths result in a royal mess anyway ...
// Unlike QFileInfo, this considers only paths with both a drive prefix and
// a subsequent (back-)slash absolute:
if (path.length() >= 3 && path.at(1) == QLatin1Char(':') && path.at(0).isLetter()
&& (path.at(2) == QLatin1Char('/') || path.at(2) == QLatin1Char('\\')))
&& (path.at(2) == QLatin1Char('/') || path.at(2) == QLatin1Char('\\'))) {
return false;
#endif
}
// (... unless, of course, they're UNC, which qmake fails on anyway)
#else
if (path.startsWith(QLatin1Char('/')))
return false;
#endif // Q_OS_WIN
return true;
}
@@ -93,6 +99,12 @@ QString IoUtils::resolvePath(const QString &baseDir, const QString &fileName)
return QString();
if (isAbsolutePath(fileName))
return QDir::cleanPath(fileName);
#ifdef Q_OS_WIN // Add drive to otherwise-absolute path:
if (fileName.at(0).unicode() == '/' || fileName.at(0).unicode() == '\\') {
Q_ASSERT(isAbsolutePath(baseDir));
return QDir::cleanPath(baseDir.left(2) + fileName);
}
#endif // Q_OS_WIN
return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName);
}
@@ -181,4 +193,105 @@ QString IoUtils::shellQuoteWin(const QString &arg)
return ret;
}
#if defined(PROEVALUATOR_FULL)
# if defined(Q_OS_WIN)
static QString windowsErrorCode()
{
wchar_t *string = 0;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&string,
0,
NULL);
QString ret = QString::fromWCharArray(string);
LocalFree((HLOCAL)string);
return ret.trimmed();
}
# endif
bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceFileName, QString *errorString)
{
# ifdef Q_OS_UNIX
struct stat st;
if (stat(referenceFileName.toLocal8Bit().constData(), &st)) {
*errorString = fL1S("Cannot stat() reference file %1: %2.").arg(referenceFileName, fL1S(strerror(errno)));
return false;
}
# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L
const struct timespec times[2] = { { 0, UTIME_NOW }, st.st_mtim };
const bool utimeError = utimensat(AT_FDCWD, targetFileName.toLocal8Bit().constData(), times, 0) < 0;
# else
struct utimbuf utb;
utb.actime = time(0);
utb.modtime = st.st_mtime;
const bool utimeError= utime(targetFileName.toLocal8Bit().constData(), &utb) < 0;
# endif
if (utimeError) {
*errorString = fL1S("Cannot touch %1: %2.").arg(targetFileName, fL1S(strerror(errno)));
return false;
}
# else
HANDLE rHand = CreateFile((wchar_t*)referenceFileName.utf16(),
GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (rHand == INVALID_HANDLE_VALUE) {
*errorString = fL1S("Cannot open reference file %1: %2").arg(referenceFileName, windowsErrorCode());
return false;
}
FILETIME ft;
GetFileTime(rHand, 0, 0, &ft);
CloseHandle(rHand);
HANDLE wHand = CreateFile((wchar_t*)targetFileName.utf16(),
GENERIC_WRITE, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (wHand == INVALID_HANDLE_VALUE) {
*errorString = fL1S("Cannot open %1: %2").arg(targetFileName, windowsErrorCode());
return false;
}
SetFileTime(wHand, 0, 0, &ft);
CloseHandle(wHand);
# endif
return true;
}
#if defined(QT_BUILD_QMAKE) && defined(Q_OS_UNIX)
bool IoUtils::readLinkTarget(const QString &symlinkPath, QString *target)
{
const QByteArray localSymlinkPath = QFile::encodeName(symlinkPath);
# if defined(__GLIBC__) && !defined(PATH_MAX)
# define PATH_CHUNK_SIZE 256
char *s = 0;
int len = -1;
int size = PATH_CHUNK_SIZE;
forever {
s = (char *)::realloc(s, size);
len = ::readlink(localSymlinkPath.constData(), s, size);
if (len < 0) {
::free(s);
break;
}
if (len < size)
break;
size *= 2;
}
# else
char s[PATH_MAX+1];
int len = readlink(localSymlinkPath.constData(), s, PATH_MAX);
# endif
if (len <= 0)
return false;
*target = QFile::decodeName(QByteArray(s, len));
# if defined(__GLIBC__) && !defined(PATH_MAX)
::free(s);
# endif
return true;
}
#endif
#endif // PROEVALUATOR_FULL
QT_END_NAMESPACE

View File

@@ -60,6 +60,12 @@ public:
#else
{ return shellQuoteWin(arg); }
#endif
#if defined(PROEVALUATOR_FULL)
static bool touchFile(const QString &targetFileName, const QString &referenceFileName, QString *errorString);
# if defined(QT_BUILD_QMAKE) && defined(Q_OS_UNIX)
static bool readLinkTarget(const QString &symlinkPath, QString *target);
# endif
#endif
};
} // namespace ProFileEvaluatorInternal

View File

@@ -196,13 +196,15 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::absoluteFileValues(
ProFileEvaluator::TemplateType ProFileEvaluator::templateType() const
{
static QString str_staticlib = QStringLiteral("staticlib");
const ProStringList &templ = d->values(ProKey("TEMPLATE"));
if (templ.count() >= 1) {
const QString &t = templ.at(0).toQString();
if (!t.compare(QLatin1String("app"), Qt::CaseInsensitive))
return TT_Application;
if (!t.compare(QLatin1String("lib"), Qt::CaseInsensitive))
return d->isActiveConfig(QStringLiteral("staticlib")) ? TT_StaticLibrary : TT_SharedLibrary;
return d->isActiveConfig(QStringRef(&str_staticlib)) ? TT_StaticLibrary : TT_SharedLibrary;
if (!t.compare(QLatin1String("script"), Qt::CaseInsensitive))
return TT_Script;
if (!t.compare(QLatin1String("aux"), Qt::CaseInsensitive))
@@ -224,6 +226,10 @@ bool ProFileEvaluator::loadNamedSpec(const QString &specDir, bool hostSpec)
bool ProFileEvaluator::accept(ProFile *pro, QMakeEvaluator::LoadFlags flags)
{
static QString str_no_include_pwd = QStringLiteral("no_include_pwd");
static QString str_plugin = QStringLiteral("plugin");
static QString str_plugin_no_share_shlib_cflags = QStringLiteral("plugin_no_share_shlib_cflags");
if (d->visitProFile(pro, QMakeHandler::EvalProjectFile, flags) != QMakeEvaluator::ReturnTrue)
return false;
@@ -232,7 +238,7 @@ bool ProFileEvaluator::accept(ProFile *pro, QMakeEvaluator::LoadFlags flags)
ProStringList &incpath = d->valuesRef(ProKey("INCLUDEPATH"));
incpath += d->values(ProKey("QMAKE_INCDIR"));
if (!d->isActiveConfig(QStringLiteral("no_include_pwd"))) {
if (!d->isActiveConfig(QStringRef(&str_no_include_pwd))) {
incpath.prepend(ProString(pro->directoryName()));
// It's pretty stupid that this is appended - it should be the second entry.
if (pro->directoryName() != d->m_outputDir)
@@ -249,8 +255,8 @@ bool ProFileEvaluator::accept(ProFile *pro, QMakeEvaluator::LoadFlags flags)
break;
case TT_SharedLibrary:
{
bool plugin = d->isActiveConfig(QStringLiteral("plugin"));
if (!plugin || !d->isActiveConfig(QStringLiteral("plugin_no_share_shlib_cflags")))
bool plugin = d->isActiveConfig(QStringRef(&str_plugin));
if (!plugin || !d->isActiveConfig(QStringRef(&str_plugin_no_share_shlib_cflags)))
cxxflags += d->values(ProKey("QMAKE_CXXFLAGS_SHLIB"));
if (plugin)
cxxflags += d->values(ProKey("QMAKE_CXXFLAGS_PLUGIN"));

View File

@@ -55,7 +55,7 @@ public:
struct SourceFile {
QString fileName;
const ProFile *proFile;
int proFileId;
};
// Call this from a concurrency-free context

View File

@@ -71,6 +71,11 @@ ProString::ProString(const QString &str) :
{
}
ProString::ProString(const QStringRef &str) :
m_string(*str.string()), m_offset(str.position()), m_length(str.size()), m_file(0), m_hash(0x80000000)
{
}
ProString::ProString(const char *str, DoPreHashing) :
m_string(QString::fromLatin1(str)), m_offset(0), m_length(qstrlen(str)), m_file(0)
{
@@ -333,7 +338,7 @@ ProString ProString::trimmed() const
QTextStream &operator<<(QTextStream &t, const ProString &str)
{
t << str.toQString(); // XXX optimize ... somehow
t << str.toQStringRef();
return t;
}
@@ -393,10 +398,13 @@ void ProStringList::removeAll(const char *str)
void ProStringList::removeEach(const ProStringList &value)
{
for (const ProString &str : value)
for (const ProString &str : value) {
if (isEmpty())
break;
if (!str.isEmpty())
removeAll(str);
}
}
void ProStringList::removeEmpty()
{
@@ -455,6 +463,14 @@ bool ProStringList::contains(const ProString &str, Qt::CaseSensitivity cs) const
return false;
}
bool ProStringList::contains(const QStringRef &str, Qt::CaseSensitivity cs) const
{
for (int i = 0; i < size(); i++)
if (!at(i).toQStringRef().compare(str, cs))
return true;
return false;
}
bool ProStringList::contains(const char *str, Qt::CaseSensitivity cs) const
{
for (int i = 0; i < size(); i++)
@@ -463,9 +479,10 @@ bool ProStringList::contains(const char *str, Qt::CaseSensitivity cs) const
return false;
}
ProFile::ProFile(const QString &fileName)
ProFile::ProFile(int id, const QString &fileName)
: m_refCount(1),
m_fileName(fileName),
m_id(id),
m_ok(true),
m_hostBuild(false)
{
@@ -482,7 +499,7 @@ ProString ProFile::getStr(const ushort *&tPtr)
{
uint len = *tPtr++;
ProString ret(items(), tPtr - tokPtr(), len);
ret.setSource(this);
ret.setSource(m_id);
tPtr += len;
return ret;
}

View File

@@ -64,13 +64,14 @@ public:
ProString();
ProString(const ProString &other);
PROITEM_EXPLICIT ProString(const QString &str);
PROITEM_EXPLICIT ProString(const QStringRef &str);
PROITEM_EXPLICIT ProString(const char *str);
ProString(const QString &str, int offset, int length);
void setValue(const QString &str);
void clear() { m_string.clear(); m_length = 0; }
ProString &setSource(const ProString &other) { m_file = other.m_file; return *this; }
ProString &setSource(const ProFile *pro) { m_file = pro; return *this; }
const ProFile *sourceFile() const { return m_file; }
ProString &setSource(int id) { m_file = id; return *this; }
int sourceFile() const { return m_file; }
ProString &prepend(const ProString &other);
ProString &append(const ProString &other, bool *pending = 0);
@@ -90,6 +91,7 @@ public:
bool operator==(const ProString &other) const { return toQStringRef() == other.toQStringRef(); }
bool operator==(const QString &other) const { return toQStringRef() == other; }
bool operator==(const QStringRef &other) const { return toQStringRef() == other; }
bool operator==(QLatin1String other) const { return toQStringRef() == other; }
bool operator==(const char *other) const { return toQStringRef() == QLatin1String(other); }
bool operator!=(const ProString &other) const { return !(*this == other); }
@@ -159,7 +161,7 @@ private:
QString m_string;
int m_offset, m_length;
const ProFile *m_file;
int m_file;
mutable uint m_hash;
QChar *prepareExtend(int extraLen, int thisTarget, int extraTarget);
uint updatedHash() const;
@@ -199,14 +201,14 @@ Q_DECLARE_TYPEINFO(ProKey, Q_MOVABLE_TYPE);
uint qHash(const ProString &str);
QString operator+(const ProString &one, const ProString &two);
inline QString operator+(const ProString &one, const QString &two)
{ return one + ProString(two); }
{ return one.toQStringRef() + two; }
inline QString operator+(const QString &one, const ProString &two)
{ return ProString(one) + two; }
{ return one + two.toQStringRef(); }
inline QString operator+(const ProString &one, const char *two)
{ return one + ProString(two); } // XXX optimize
{ return one.toQStringRef() + QLatin1String(two); }
inline QString operator+(const char *one, const ProString &two)
{ return ProString(one) + two; } // XXX optimize
{ return QLatin1String(one) + two.toQStringRef(); }
inline QString &operator+=(QString &that, const ProString &other)
{ return that += other.toQStringRef(); }
@@ -244,6 +246,7 @@ public:
void removeDuplicates();
bool contains(const ProString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
{ return contains(ProString(str), cs); }
bool contains(const char *str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -320,6 +323,9 @@ enum ProToken {
// - function name: hash (2), length (1), chars (length)
// - body length (2)
// - body + TokTerminator (body length)
TokBypassNesting, // escape from function local variable scopes:
// - block length (2)
// - block + TokTerminator (block length)
TokMask = 0xff,
TokQuoted = 0x100, // The expression is quoted => join expanded stringlist
TokNewStr = 0x200 // Next stringlist element
@@ -328,9 +334,10 @@ enum ProToken {
class QMAKE_EXPORT ProFile
{
public:
explicit ProFile(const QString &fileName);
ProFile(int id, const QString &fileName);
~ProFile();
int id() const { return m_id; }
QString fileName() const { return m_fileName; }
QString directoryName() const { return m_directoryName; }
const QString &items() const { return m_proitems; }
@@ -355,6 +362,7 @@ private:
QString m_proitems;
QString m_fileName;
QString m_directoryName;
int m_id;
bool m_ok;
bool m_hostBuild;
};

View File

@@ -176,7 +176,7 @@ QString ProWriter::compileScope(const QString &scope)
if (scope.isEmpty())
return QString();
QMakeParser parser(0, 0, 0);
ProFile *includeFile = parser.parsedProBlock(QStringRef(&scope), QLatin1String("no-file"), 1);
ProFile *includeFile = parser.parsedProBlock(QStringRef(&scope), 0, QLatin1String("no-file"), 1);
if (!includeFile)
return QString();
QString result = includeFile->items();

View File

@@ -52,7 +52,6 @@
#ifdef Q_OS_UNIX
#include <time.h>
#include <utime.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
@@ -98,7 +97,7 @@ enum TestFunc {
T_EXISTS, T_EXPORT, T_CLEAR, T_UNSET, T_EVAL, T_CONFIG, T_SYSTEM,
T_DEFINED, T_DISCARD_FROM, T_CONTAINS, T_INFILE,
T_COUNT, T_ISEMPTY, T_PARSE_JSON, T_INCLUDE, T_LOAD, T_DEBUG, T_LOG, T_MESSAGE, T_WARNING, T_ERROR, T_IF,
T_MKPATH, T_WRITE_FILE, T_TOUCH, T_CACHE
T_MKPATH, T_WRITE_FILE, T_TOUCH, T_CACHE, T_RELOAD_PROPERTIES
};
void QMakeEvaluator::initFunctionStatics()
@@ -197,6 +196,7 @@ void QMakeEvaluator::initFunctionStatics()
{ "write_file", T_WRITE_FILE },
{ "touch", T_TOUCH },
{ "cache", T_CACHE },
{ "reload_properties", T_RELOAD_PROPERTIES },
};
statics.functions.reserve((int)(sizeof(testInits)/sizeof(testInits[0])));
for (unsigned i = 0; i < sizeof(testInits)/sizeof(testInits[0]); ++i)
@@ -251,23 +251,6 @@ QMakeEvaluator::getMemberArgs(const ProKey &func, int srclen, const ProStringLis
return true;
}
#if defined(Q_OS_WIN) && defined(PROEVALUATOR_FULL)
static QString windowsErrorCode()
{
wchar_t *string = 0;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&string,
0,
NULL);
QString ret = QString::fromWCharArray(string);
LocalFree((HLOCAL)string);
return ret.trimmed();
}
#endif
QString
QMakeEvaluator::quoteValue(const ProString &val)
{
@@ -392,14 +375,47 @@ static void addJsonValue(const QJsonValue &value, const QString &keyPrefix, ProV
}
}
struct ErrorPosition {
int line;
int column;
};
static ErrorPosition calculateErrorPosition(const QByteArray &json, int offset)
{
ErrorPosition pos = { 0, 0 };
offset--; // offset is 1-based, switching to 0-based
for (int i = 0; i < offset; ++i) {
switch (json.at(i)) {
case '\n':
pos.line++;
pos.column = 0;
break;
case '\r':
break;
case '\t':
pos.column = (pos.column + 8) & ~7;
break;
default:
pos.column++;
break;
}
}
// Lines and columns in text editors are 1-based:
pos.line++;
pos.column++;
return pos;
}
QMakeEvaluator::VisitReturn QMakeEvaluator::parseJsonInto(const QByteArray &json, const QString &into, ProValueMap *value)
{
QJsonParseError error;
QJsonDocument document = QJsonDocument::fromJson(json, &error);
if (document.isNull()) {
if (error.error != QJsonParseError::NoError)
evalError(fL1S("Error parsing json at offset %1: %2")
.arg(error.offset).arg(error.errorString()));
if (error.error != QJsonParseError::NoError) {
ErrorPosition errorPos = calculateErrorPosition(json, error.offset);
evalError(fL1S("Error parsing JSON at %1:%2: %3")
.arg(errorPos.line).arg(errorPos.column).arg(error.errorString()));
}
return QMakeEvaluator::ReturnFalse;
}
@@ -420,13 +436,16 @@ QMakeEvaluator::VisitReturn
QMakeEvaluator::writeFile(const QString &ctx, const QString &fn, QIODevice::OpenMode mode,
QMakeVfs::VfsFlags flags, const QString &contents)
{
int oldId = m_vfs->idForFileName(fn, flags | QMakeVfs::VfsAccessedOnly);
int id = m_vfs->idForFileName(fn, flags | QMakeVfs::VfsCreate);
QString errStr;
if (!m_vfs->writeFile(fn, mode, flags, contents, &errStr)) {
if (!m_vfs->writeFile(id, mode, flags, contents, &errStr)) {
evalError(fL1S("Cannot write %1file %2: %3")
.arg(ctx, QDir::toNativeSeparators(fn), errStr));
return ReturnFalse;
}
m_parser->discardFileFromCache(fn);
if (oldId)
m_parser->discardFileFromCache(oldId);
return ReturnTrue;
}
@@ -522,11 +541,9 @@ void QMakeEvaluator::populateDeps(
}
}
ProStringList QMakeEvaluator::evaluateBuiltinExpand(
int func_t, const ProKey &func, const ProStringList &args)
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
int func_t, const ProKey &func, const ProStringList &args, ProStringList &ret)
{
ProStringList ret;
traceMsg("calling built-in $$%s(%s)", dbgKey(func), dbgSepStrList(args));
switch (func_t) {
@@ -540,8 +557,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
int end = -1;
if (func_t == E_SECTION) {
if (args.count() != 3 && args.count() != 4) {
evalError(fL1S("%1(var) section(var, sep, begin, end) requires"
" three or four arguments.").arg(func.toQString(m_tmp1)));
evalError(fL1S("section(var, sep, begin, end) requires three or four arguments."));
} else {
var = args[0];
sep = args.at(1).toQString();
@@ -567,8 +583,8 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
if (regexp) {
QRegExp sepRx(sep);
for (const ProString &str : strings) {
const QString &rstr = str.toQString(m_tmp1).section(sepRx, beg, end);
ret << (rstr.isSharedWith(m_tmp1) ? str : ProString(rstr).setSource(str));
const QString &rstr = str.toQString(m_tmp[m_toggle ^= 1]).section(sepRx, beg, end);
ret << (rstr.isSharedWith(m_tmp[m_toggle]) ? str : ProString(rstr).setSource(str));
}
} else {
for (const ProString &str : strings) {
@@ -696,9 +712,9 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
after = args[3];
const ProStringList &var = values(map(args.at(0)));
if (!var.isEmpty()) {
const ProFile *src = currentProFile();
int src = currentFileId();
for (const ProString &v : var)
if (const ProFile *s = v.sourceFile()) {
if (int s = v.sourceFile()) {
src = s;
break;
}
@@ -714,9 +730,9 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
const QString &sep = (args.count() == 2) ? args.at(1).toQString(m_tmp1) : statics.field_sep;
const auto vars = values(map(args.at(0)));
for (const ProString &var : vars) {
const auto splits = var.toQString(m_tmp2).split(sep);
for (const QString &splt : splits)
ret << (splt.isSharedWith(m_tmp2) ? var : ProString(splt).setSource(var));
const auto splits = var.toQStringRef().split(sep);
for (const auto &splt : splits)
ret << ProString(splt).setSource(var);
}
}
break;
@@ -802,7 +818,8 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
if (args.count() < 1 || args.count() > 2) {
evalError(fL1S("cat(file, singleline=true) requires one or two arguments."));
} else {
const QString &file = args.at(0).toQString(m_tmp1);
QString fn = resolvePath(m_option->expandEnvVars(args.at(0).toQString(m_tmp1)));
fn.detach();
bool blob = false;
bool lines = false;
@@ -817,7 +834,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
lines = true;
}
QFile qfile(resolvePath(m_option->expandEnvVars(file)));
QFile qfile(fn);
if (qfile.open(QIODevice::ReadOnly)) {
QTextStream stream(&qfile);
if (blob) {
@@ -868,12 +885,10 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
evalError(fL1S("find(var, str) requires two arguments."));
} else {
QRegExp regx(args.at(1).toQString());
int t = 0;
const auto vals = values(map(args.at(0)));
for (const ProString &val : vals) {
if (regx.indexIn(val.toQString(m_tmp[t])) != -1)
if (regx.indexIn(val.toQString(m_tmp[m_toggle ^= 1])) != -1)
ret += val;
t ^= 1;
}
}
break;
@@ -895,7 +910,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
lines = true;
}
int exitCode;
QByteArray bytes = getCommandOutput(args.at(0).toQString(m_tmp2), &exitCode);
QByteArray bytes = getCommandOutput(args.at(0).toQString(), &exitCode);
if (args.count() > 2 && !args.at(2).isEmpty()) {
m_valuemapStack.top()[args.at(2).toKey()] =
ProStringList(ProString(QString::number(exitCode)));
@@ -1049,27 +1064,38 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
dirs.append(fname + QLatin1Char('/'));
}
if (regex.exactMatch(qdir[i]))
ret += ProString(fname).setSource(currentProFile());
ret += ProString(fname).setSource(currentFileId());
}
}
}
break;
#ifdef PROEVALUATOR_FULL
case E_PROMPT: {
if (args.count() != 1) {
evalError(fL1S("prompt(question) requires one argument."));
if (args.count() != 1 && args.count() != 2) {
evalError(fL1S("prompt(question, [decorate=true]) requires one or two arguments."));
// } else if (currentFileName() == QLatin1String("-")) {
// evalError(fL1S("prompt(question) cannot be used when '-o -' is used"));
} else {
QString msg = m_option->expandEnvVars(args.at(0).toQString(m_tmp1));
bool decorate = true;
if (args.count() == 2)
decorate = isTrue(args.at(1));
if (decorate) {
if (!msg.endsWith(QLatin1Char('?')))
msg += QLatin1Char('?');
fprintf(stderr, "Project PROMPT: %s ", qPrintable(msg));
} else {
fputs(qPrintable(msg), stderr);
}
QFile qfile;
if (qfile.open(stdin, QIODevice::ReadOnly)) {
QTextStream t(&qfile);
const QString &line = t.readLine();
if (t.atEnd()) {
fputs("\n", stderr);
evalError(fL1S("Unexpected EOF."));
return ReturnError;
}
ret = split_value_list(QStringRef(&line));
}
}
@@ -1086,7 +1112,11 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
QString rstr = val.toQString(m_tmp1);
QString copy = rstr; // Force a detach on modify
rstr.replace(before, after);
ret << (rstr.isSharedWith(m_tmp1) ? val : ProString(rstr).setSource(val));
ret << (rstr.isSharedWith(m_tmp1)
? val
: rstr.isSharedWith(m_tmp2)
? args.at(2)
: ProString(rstr).setSource(val));
}
}
break;
@@ -1144,9 +1174,9 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
if (args.count() > 2) {
evalError(fL1S("absolute_path(path[, base]) requires one or two arguments."));
} else {
QString rstr = QDir::cleanPath(
QDir(args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory())
.absoluteFilePath(args.at(0).toQString(m_tmp1)));
QString arg = args.at(0).toQString(m_tmp1);
QString baseDir = args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory();
QString rstr = arg.isEmpty() ? baseDir : IoUtils::resolvePath(baseDir, arg);
ret << (rstr.isSharedWith(m_tmp1)
? args.at(0)
: args.count() > 1 && rstr.isSharedWith(m_tmp2)
@@ -1158,9 +1188,10 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
if (args.count() > 2) {
evalError(fL1S("relative_path(path[, base]) requires one or two arguments."));
} else {
QDir baseDir(args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory());
QString rstr = baseDir.relativeFilePath(baseDir.absoluteFilePath(
args.at(0).toQString(m_tmp1)));
QString arg = args.at(0).toQString(m_tmp1);
QString baseDir = args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory();
QString absArg = arg.isEmpty() ? baseDir : IoUtils::resolvePath(baseDir, arg);
QString rstr = QDir(baseDir).relativeFilePath(absArg);
ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0)));
}
break;
@@ -1239,7 +1270,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
break;
}
return ret;
return ReturnTrue;
}
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
@@ -1305,7 +1336,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ReturnFalse;
}
QString fn = resolvePath(args.at(0).toQString(m_tmp1));
ProFile *pro = m_parser->parsedProFile(fn, QMakeParser::ParseOnlyCached);
QMakeVfs::VfsFlags flags = (m_cumulative ? QMakeVfs::VfsCumulative : QMakeVfs::VfsExact);
int pro = m_vfs->idForFileName(fn, flags | QMakeVfs::VfsAccessedOnly);
if (!pro)
return ReturnFalse;
ProValueMap &vmap = m_valuemapStack.first();
@@ -1324,7 +1356,22 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
}
++vit;
}
pro->deref();
for (auto fit = m_functionDefs.testFunctions.begin(); fit != m_functionDefs.testFunctions.end(); ) {
if (fit->pro()->id() == pro)
fit = m_functionDefs.testFunctions.erase(fit);
else
++fit;
}
for (auto fit = m_functionDefs.replaceFunctions.begin(); fit != m_functionDefs.replaceFunctions.end(); ) {
if (fit->pro()->id() == pro)
fit = m_functionDefs.replaceFunctions.erase(fit);
else
++fit;
}
ProStringList &iif = m_valuemapStack.first()[ProKey("QMAKE_INTERNAL_INCLUDED_FILES")];
int idx = iif.indexOf(ProString(fn));
if (idx >= 0)
iif.removeAt(idx);
return ReturnTrue;
}
case T_INFILE:
@@ -1346,12 +1393,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
copy.detach();
regx.setPattern(copy);
}
int t = 0;
const auto strings = vars.value(map(args.at(1)));
for (const ProString &s : strings) {
if ((!regx.isEmpty() && regx.exactMatch(s.toQString(m_tmp[t]))) || s == qry)
if ((!regx.isEmpty() && regx.exactMatch(s.toQString(m_tmp[m_toggle ^= 1]))) || s == qry)
return ReturnTrue;
t ^= 1;
}
}
return ReturnFalse;
@@ -1365,7 +1410,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
VisitReturn ret = ReturnFalse;
QString contents = args.join(statics.field_sep);
ProFile *pro = m_parser->parsedProBlock(QStringRef(&contents),
m_current.pro->fileName(), m_current.line);
0, m_current.pro->fileName(), m_current.line);
if (m_cumulative || pro->isOk()) {
m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr());
@@ -1389,13 +1434,13 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ReturnFalse;
}
if (args.count() == 1)
return returnBool(isActiveConfig(args.at(0).toQString(m_tmp2)));
const QStringList &mutuals = args.at(1).toQString(m_tmp2).split(QLatin1Char('|'));
return returnBool(isActiveConfig(args.at(0).toQStringRef()));
const auto mutuals = args.at(1).toQStringRef().split(QLatin1Char('|'));
const ProStringList &configs = values(statics.strCONFIG);
for (int i = configs.size() - 1; i >= 0; i--) {
for (int mut = 0; mut < mutuals.count(); mut++) {
if (configs[i] == mutuals[mut].trimmed())
if (configs[i].toQStringRef() == mutuals[mut].trimmed())
return returnBool(configs[i] == args[0]);
}
}
@@ -1416,21 +1461,19 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
}
const ProStringList &l = values(map(args.at(0)));
if (args.count() == 2) {
int t = 0;
for (int i = 0; i < l.size(); ++i) {
const ProString &val = l[i];
if ((!regx.isEmpty() && regx.exactMatch(val.toQString(m_tmp[t]))) || val == qry)
if ((!regx.isEmpty() && regx.exactMatch(val.toQString(m_tmp[m_toggle ^= 1]))) || val == qry)
return ReturnTrue;
t ^= 1;
}
} else {
const QStringList &mutuals = args.at(2).toQString(m_tmp3).split(QLatin1Char('|'));
const auto mutuals = args.at(2).toQStringRef().split(QLatin1Char('|'));
for (int i = l.size() - 1; i >= 0; i--) {
const ProString val = l[i];
for (int mut = 0; mut < mutuals.count(); mut++) {
if (val == mutuals[mut].trimmed()) {
if (val.toQStringRef() == mutuals[mut].trimmed()) {
return returnBool((!regx.isEmpty()
&& regx.exactMatch(val.toQString(m_tmp2)))
&& regx.exactMatch(val.toQString(m_tmp[m_toggle ^= 1])))
|| val == qry);
}
}
@@ -1495,7 +1538,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ReturnFalse;
}
return returnBool(values(map(args.at(0))).join(statics.field_sep)
== args.at(1).toQString(m_tmp1));
== args.at(1).toQStringRef());
case T_VERSION_AT_LEAST:
case T_VERSION_AT_MOST: {
if (args.count() != 2) {
@@ -1666,7 +1709,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
#ifndef QT_BOOTSTRAPPED
QProcess proc;
proc.setProcessChannelMode(QProcess::ForwardedChannels);
runProcess(&proc, args.at(0).toQString(m_tmp2));
runProcess(&proc, args.at(0).toQString());
return returnBool(proc.exitStatus() == QProcess::NormalExit && proc.exitCode() == 0);
#else
int ec = system((QLatin1String("cd ")
@@ -1703,8 +1746,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ReturnTrue;
int slsh = file.lastIndexOf(QLatin1Char('/'));
QString fn = file.mid(slsh+1);
fn.detach();
if (fn.contains(QLatin1Char('*')) || fn.contains(QLatin1Char('?'))) {
QString dirstr = file.left(slsh+1);
dirstr.detach();
if (!QDir(dirstr).entryList(QStringList(fn)).isEmpty())
return ReturnTrue;
}
@@ -1717,7 +1762,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ReturnFalse;
}
#ifdef PROEVALUATOR_FULL
const QString &fn = resolvePath(args.at(0).toQString(m_tmp1));
QString fn = resolvePath(args.at(0).toQString(m_tmp1));
fn.detach();
if (!QDir::current().mkpath(fn)) {
evalError(fL1S("Cannot create directory %1.").arg(QDir::toNativeSeparators(fn)));
return ReturnFalse;
@@ -1740,13 +1786,12 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
if (args.count() >= 3) {
const auto opts = split_value_list(args.at(2).toQStringRef());
for (const ProString &opt : opts) {
opt.toQString(m_tmp3);
if (m_tmp3 == QLatin1String("append")) {
if (opt == QLatin1String("append")) {
mode = QIODevice::Append;
} else if (m_tmp3 == QLatin1String("exe")) {
} else if (opt == QLatin1String("exe")) {
flags |= QMakeVfs::VfsExecutable;
} else {
evalError(fL1S("write_file(): invalid flag %1.").arg(m_tmp3));
evalError(fL1S("write_file(): invalid flag %1.").arg(opt.toQString(m_tmp3)));
return ReturnFalse;
}
}
@@ -1764,40 +1809,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
#ifdef PROEVALUATOR_FULL
const QString &tfn = resolvePath(args.at(0).toQString(m_tmp1));
const QString &rfn = resolvePath(args.at(1).toQString(m_tmp2));
#ifdef Q_OS_UNIX
struct stat st;
if (stat(rfn.toLocal8Bit().constData(), &st)) {
evalError(fL1S("Cannot stat() reference file %1: %2.").arg(rfn, fL1S(strerror(errno))));
QString error;
if (!IoUtils::touchFile(tfn, rfn, &error)) {
evalError(error);
return ReturnFalse;
}
struct utimbuf utb;
utb.actime = time(0);
utb.modtime = st.st_mtime;
if (utime(tfn.toLocal8Bit().constData(), &utb)) {
evalError(fL1S("Cannot touch %1: %2.").arg(tfn, fL1S(strerror(errno))));
return ReturnFalse;
}
#else
HANDLE rHand = CreateFile((wchar_t*)rfn.utf16(),
GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (rHand == INVALID_HANDLE_VALUE) {
evalError(fL1S("Cannot open reference file %1: %2").arg(rfn, windowsErrorCode()));
return ReturnFalse;
}
FILETIME ft;
GetFileTime(rHand, 0, 0, &ft);
CloseHandle(rHand);
HANDLE wHand = CreateFile((wchar_t*)tfn.utf16(),
GENERIC_WRITE, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (wHand == INVALID_HANDLE_VALUE) {
evalError(fL1S("Cannot open %1: %2").arg(tfn, windowsErrorCode()));
return ReturnFalse;
}
SetFileTime(wHand, 0, 0, &ft);
CloseHandle(wHand);
#endif
#endif
return ReturnTrue;
}
@@ -1813,21 +1829,20 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
if (args.count() >= 2) {
const auto opts = split_value_list(args.at(1).toQStringRef());
for (const ProString &opt : opts) {
opt.toQString(m_tmp3);
if (m_tmp3 == QLatin1String("transient")) {
if (opt == QLatin1String("transient")) {
persist = false;
} else if (m_tmp3 == QLatin1String("super")) {
} else if (opt == QLatin1String("super")) {
target = TargetSuper;
} else if (m_tmp3 == QLatin1String("stash")) {
} else if (opt == QLatin1String("stash")) {
target = TargetStash;
} else if (m_tmp3 == QLatin1String("set")) {
} else if (opt == QLatin1String("set")) {
mode = CacheSet;
} else if (m_tmp3 == QLatin1String("add")) {
} else if (opt == QLatin1String("add")) {
mode = CacheAdd;
} else if (m_tmp3 == QLatin1String("sub")) {
} else if (opt == QLatin1String("sub")) {
mode = CacheSub;
} else {
evalError(fL1S("cache(): invalid flag %1.").arg(m_tmp3));
evalError(fL1S("cache(): invalid flag %1.").arg(opt.toQString(m_tmp3)));
return ReturnFalse;
}
}
@@ -1969,6 +1984,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
}
return writeFile(fL1S("cache "), fn, QIODevice::Append, flags, varstr);
}
case T_RELOAD_PROPERTIES:
#ifdef QT_BUILD_QMAKE
m_option->reloadProperties();
#endif
return ReturnTrue;
default:
evalError(fL1S("Function '%1' is not implemented.").arg(function.toQString(m_tmp1)));
return ReturnFalse;

View File

@@ -149,6 +149,7 @@ void QMakeEvaluator::initStatics()
statics.strhost_build = QLatin1String("host_build");
statics.strTEMPLATE = ProKey("TEMPLATE");
statics.strQMAKE_PLATFORM = ProKey("QMAKE_PLATFORM");
statics.strQMAKE_DIR_SEP = ProKey("QMAKE_DIR_SEP");
statics.strQMAKESPEC = ProKey("QMAKESPEC");
#ifdef PROEVALUATOR_FULL
statics.strREQUIRES = ProKey("REQUIRES");
@@ -222,6 +223,7 @@ QMakeEvaluator::QMakeEvaluator(QMakeGlobals *option, QMakeParser *parser, QMakeV
m_skipLevel = 0;
#endif
m_listCount = 0;
m_toggle = 0;
m_valuemapStack.push(ProValueMap());
m_valuemapInited = false;
}
@@ -267,13 +269,13 @@ void QMakeEvaluator::skipHashStr(const ushort *&tokPtr)
// FIXME: this should not build new strings for direct sections.
// Note that the E_SPRINTF and E_LIST implementations rely on the deep copy.
ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, const ProFile *source)
ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, int source)
{
QString build;
ProStringList ret;
if (!source)
source = currentProFile();
source = currentFileId();
const QChar *vals_data = vals.data();
const int vals_len = vals.length();
@@ -591,6 +593,24 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
tokPtr += blockLen;
okey = true, or_op = false; // force next evaluation
break;
case TokBypassNesting:
blockLen = getBlockLen(tokPtr);
if ((m_cumulative || okey != or_op) && blockLen) {
ProValueMapStack savedValuemapStack = m_valuemapStack;
m_valuemapStack.clear();
m_valuemapStack.append(savedValuemapStack.takeFirst());
traceMsg("visiting nesting-bypassing block");
ret = visitProBlock(tokPtr);
traceMsg("visited nesting-bypassing block");
savedValuemapStack.prepend(m_valuemapStack.first());
m_valuemapStack = savedValuemapStack;
} else {
traceMsg("skipped nesting-bypassing block");
ret = ReturnTrue;
}
tokPtr += blockLen;
okey = true, or_op = false; // force next evaluation
break;
case TokTestDef:
case TokReplaceDef:
if (m_cumulative || okey != or_op) {
@@ -626,7 +646,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
evalError(fL1S("Conditional must expand to exactly one word."));
okey = false;
} else {
okey = isActiveConfig(curr.at(0).toQString(m_tmp2), true);
okey = isActiveConfig(curr.at(0).toQStringRef(), true);
traceMsg("condition %s is %s", dbgStr(curr.at(0)), dbgBool(okey));
okey ^= invert;
}
@@ -753,7 +773,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
}
infinite = true;
} else {
const QString &itl = it_list.toQString(m_tmp1);
const QStringRef &itl = it_list.toQStringRef();
int dotdot = itl.indexOf(statics.strDotDot);
if (dotdot != -1) {
bool ok;
@@ -850,13 +870,13 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
ProStringList varVal;
if (expandVariableReferences(tokPtr, sizeHint, &varVal, true) == ReturnError)
return ReturnError;
const QString &val = varVal.at(0).toQString(m_tmp1);
const QStringRef &val = varVal.at(0).toQStringRef();
if (val.length() < 4 || val.at(0) != QLatin1Char('s')) {
evalError(fL1S("The ~= operator can handle only the s/// function."));
return ReturnTrue;
}
QChar sep = val.at(1);
QStringList func = val.split(sep);
auto func = val.split(sep);
if (func.count() < 3 || func.count() > 4) {
evalError(fL1S("The s/// function expects 3 or 4 arguments."));
return ReturnTrue;
@@ -868,8 +888,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
case_sense = func[3].indexOf(QLatin1Char('i')) == -1;
quote = func[3].indexOf(QLatin1Char('q')) != -1;
}
QString pattern = func[1];
QString replace = func[2];
QString pattern = func[1].toString();
QString replace = func[2].toString();
if (quote)
pattern = QRegExp::escape(pattern);
@@ -917,11 +937,14 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
setTemplate();
else if (varName == statics.strQMAKE_PLATFORM)
m_featureRoots = 0;
else if (varName == statics.strQMAKE_DIR_SEP)
m_dirSep = first(varName);
else if (varName == statics.strQMAKESPEC) {
if (!values(varName).isEmpty()) {
QString spec = values(varName).first().toQString();
if (IoUtils::isAbsolutePath(spec)) {
m_qmakespec = spec;
m_qmakespecName = IoUtils::fileName(m_qmakespec).toString();
m_featureRoots = 0;
}
}
@@ -947,11 +970,9 @@ void QMakeEvaluator::setTemplate()
values.erase(values.begin() + 1, values.end());
}
if (!m_option->user_template_prefix.isEmpty()) {
QString val = values.first().toQString(m_tmp1);
if (!val.startsWith(m_option->user_template_prefix)) {
val.prepend(m_option->user_template_prefix);
values = ProStringList(ProString(val));
}
ProString val = values.first();
if (!val.startsWith(m_option->user_template_prefix))
values = ProStringList(ProString(m_option->user_template_prefix + val));
}
}
@@ -968,6 +989,13 @@ static ProString msvcBinDirToQMakeArch(QString subdir)
subdir = subdir.toLower();
if (subdir == QLatin1String("amd64"))
return ProString("x86_64");
// Since 2017 the folder structure from here is HostX64|X86/x64|x86
idx = subdir.indexOf(QLatin1Char('\\'));
if (idx == -1)
return ProString("x86");
subdir.remove(0, idx + 1);
if (subdir == QLatin1String("x64"))
return ProString("x86_64");
return ProString(subdir);
}
@@ -1062,8 +1090,12 @@ void QMakeEvaluator::loadDefaults()
vars[ProKey("QMAKE_HOST.arch")] << archStr;
# if defined(Q_CC_MSVC) // ### bogus condition, but nobody x-builds for msvc with a different qmake
// Since VS 2017 we need VCToolsInstallDir instead of VCINSTALLDIR
QString vcInstallDir = m_option->getEnv(QLatin1String("VCToolsInstallDir"));
if (vcInstallDir.isEmpty())
vcInstallDir = m_option->getEnv(QLatin1String("VCINSTALLDIR"));
vars[ProKey("QMAKE_TARGET.arch")] = msvcArchitecture(
m_option->getEnv(QLatin1String("VCINSTALLDIR")),
vcInstallDir,
m_option->getEnv(QLatin1String("PATH")));
# endif
#elif defined(Q_OS_UNIX)
@@ -1187,8 +1219,6 @@ bool QMakeEvaluator::loadSpecInternal()
// This also ensures that m_featureRoots is valid.
if (evaluateFeatureFile(QLatin1String("spec_post.prf")) != ReturnTrue)
return false;
// The MinGW and x-build specs may change the separator; $$shell_{path,quote}() need it
m_dirSep = first(ProKey("QMAKE_DIR_SEP"));
return true;
}
@@ -1280,7 +1310,7 @@ void QMakeEvaluator::setupProject()
{
setTemplate();
ProValueMap &vars = m_valuemapStack.top();
ProFile *proFile = currentProFile();
int proFile = currentFileId();
vars[ProKey("TARGET")] << ProString(QFileInfo(currentFileName()).baseName()).setSource(proFile);
vars[ProKey("_PRO_FILE_")] << ProString(currentFileName()).setSource(proFile);
vars[ProKey("_PRO_FILE_PWD_")] << ProString(currentDirectory()).setSource(proFile);
@@ -1290,7 +1320,7 @@ void QMakeEvaluator::setupProject()
void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where)
{
if (!cmds.isEmpty()) {
ProFile *pro = m_parser->parsedProBlock(QStringRef(&cmds), where, -1);
ProFile *pro = m_parser->parsedProBlock(QStringRef(&cmds), 0, where, -1);
if (pro->isOk()) {
m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr());
@@ -1411,6 +1441,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
if (flags & LoadPreFiles) {
setupProject();
if (!m_option->extra_cmds[QMakeEvalEarly].isEmpty())
evaluateCommand(m_option->extra_cmds[QMakeEvalEarly], fL1S("(command line -early)"));
for (ProValueMap::ConstIterator it = m_extraVars.constBegin();
it != m_extraVars.constEnd(); ++it)
m_valuemapStack.first().insert(it.key(), it.value());
@@ -1422,8 +1455,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
if ((vr = evaluateFeatureFile(QLatin1String("default_pre.prf"))) == ReturnError)
goto failed;
if (!m_option->precmds.isEmpty()) {
evaluateCommand(m_option->precmds, fL1S("(command line)"));
if (!m_option->extra_cmds[QMakeEvalBefore].isEmpty()) {
evaluateCommand(m_option->extra_cmds[QMakeEvalBefore], fL1S("(command line)"));
// Again, after user configs, to override them
applyExtraConfigs();
@@ -1436,7 +1469,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
debugMsg(1, "done visiting file %s", qPrintable(pro->fileName()));
if (flags & LoadPostFiles) {
evaluateCommand(m_option->postcmds, fL1S("(command line -after)"));
evaluateCommand(m_option->extra_cmds[QMakeEvalAfter], fL1S("(command line -after)"));
// Again, to ensure the project does not mess with us.
// Specifically, do not allow a project to override debug/release within a
@@ -1446,6 +1479,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
if ((vr = evaluateFeatureFile(QLatin1String("default_post.prf"))) == ReturnError)
goto failed;
if (!m_option->extra_cmds[QMakeEvalLate].isEmpty())
evaluateCommand(m_option->extra_cmds[QMakeEvalLate], fL1S("(command line -late)"));
if ((vr = evaluateConfigFeatures()) == ReturnError)
goto failed;
}
@@ -1493,7 +1529,7 @@ void QMakeEvaluator::updateFeaturePaths()
feature_roots += m_option->getPathListEnv(QLatin1String("QMAKEFEATURES"));
feature_roots += m_qmakefeatures;
feature_roots += m_option->splitPathList(
m_option->propertyValue(ProKey("QMAKEFEATURES")).toQString(m_mtmp));
m_option->propertyValue(ProKey("QMAKEFEATURES")).toQString());
QStringList feature_bases;
if (!m_buildRoot.isEmpty()) {
@@ -1568,6 +1604,14 @@ ProFile *QMakeEvaluator::currentProFile() const
return 0;
}
int QMakeEvaluator::currentFileId() const
{
ProFile *pro = currentProFile();
if (pro)
return pro->id();
return 0;
}
QString QMakeEvaluator::currentFileName() const
{
ProFile *pro = currentProFile();
@@ -1584,7 +1628,7 @@ QString QMakeEvaluator::currentDirectory() const
return QString();
}
bool QMakeEvaluator::isActiveConfig(const QString &config, bool regex)
bool QMakeEvaluator::isActiveConfig(const QStringRef &config, bool regex)
{
// magic types for easy flipping
if (config == statics.strtrue)
@@ -1596,21 +1640,17 @@ bool QMakeEvaluator::isActiveConfig(const QString &config, bool regex)
return m_hostBuild;
if (regex && (config.contains(QLatin1Char('*')) || config.contains(QLatin1Char('?')))) {
QString cfg = config;
cfg.detach(); // Keep m_tmp out of QRegExp's cache
QRegExp re(cfg, Qt::CaseSensitive, QRegExp::Wildcard);
QRegExp re(config.toString(), Qt::CaseSensitive, QRegExp::Wildcard);
// mkspecs
if (re.exactMatch(m_qmakespecName))
return true;
// CONFIG variable
int t = 0;
const auto configValues = values(statics.strCONFIG);
for (const ProString &configValue : configValues) {
if (re.exactMatch(configValue.toQString(m_tmp[t])))
if (re.exactMatch(configValue.toQString(m_tmp[m_toggle ^= 1])))
return true;
t ^= 1;
}
} else {
// mkspecs
@@ -1618,7 +1658,7 @@ bool QMakeEvaluator::isActiveConfig(const QString &config, bool regex)
return true;
// CONFIG variable
if (values(statics.strCONFIG).contains(ProString(config)))
if (values(statics.strCONFIG).contains(config))
return true;
}
@@ -1713,7 +1753,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBoolFunction(
if (ret.at(0) == statics.strtrue)
return ReturnTrue;
bool ok;
int val = ret.at(0).toQString(m_tmp1).toInt(&ok);
int val = ret.at(0).toInt(&ok);
if (ok) {
if (val)
return ReturnTrue;
@@ -1762,8 +1802,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpandFunction(
ProStringList args;
if (expandVariableReferences(tokPtr, 5, &args, true) == ReturnError)
return ReturnError;
*ret = evaluateBuiltinExpand(func_t, func, args);
return ReturnTrue;
return evaluateBuiltinExpand(func_t, func, args, *ret);
}
QHash<ProKey, ProFunctionDef>::ConstIterator it =
@@ -1785,7 +1824,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional(
const QStringRef &cond, const QString &where, int line)
{
VisitReturn ret = ReturnFalse;
ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar);
ProFile *pro = m_parser->parsedProBlock(cond, 0, where, line, QMakeParser::TestGrammar);
if (pro->isOk()) {
m_locationStack.push(m_current);
ret = visitProBlock(pro, pro->tokPtr());

View File

@@ -173,12 +173,13 @@ public:
void setTemplate();
ProStringList split_value_list(const QStringRef &vals, const ProFile *source = 0);
ProStringList split_value_list(const QStringRef &vals, int source = 0);
VisitReturn expandVariableReferences(const ushort *&tokPtr, int sizeHint, ProStringList *ret, bool joined);
QString currentFileName() const;
QString currentDirectory() const;
ProFile *currentProFile() const;
int currentFileId() const;
QString resolvePath(const QString &fileName) const
{ return QMakeInternal::IoUtils::resolvePath(currentDirectory(), fileName); }
@@ -209,7 +210,7 @@ public:
VisitReturn evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr, ProStringList *ret);
VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr);
ProStringList evaluateBuiltinExpand(int func_t, const ProKey &function, const ProStringList &args);
VisitReturn evaluateBuiltinExpand(int func_t, const ProKey &function, const ProStringList &args, ProStringList &ret);
VisitReturn evaluateBuiltinConditional(int func_t, const ProKey &function, const ProStringList &args);
VisitReturn evaluateConditional(const QStringRef &cond, const QString &where, int line = -1);
@@ -220,7 +221,7 @@ public:
void updateMkspecPaths();
void updateFeaturePaths();
bool isActiveConfig(const QString &config, bool regex = false);
bool isActiveConfig(const QStringRef &config, bool regex = false);
void populateDeps(
const ProStringList &deps, const ProString &prefix, const ProStringList &suffixes,
@@ -282,6 +283,7 @@ public:
QString m_outputDir;
int m_listCount;
int m_toggle;
bool m_valuemapInited;
bool m_hostBuild;
QString m_qmakespec;
@@ -301,7 +303,6 @@ public:
ProStringList m_returnValue;
ProValueMapStack m_valuemapStack; // VariableName must be us-ascii, the content however can be non-us-ascii.
QString m_tmp1, m_tmp2, m_tmp3, m_tmp[2]; // Temporaries for efficient toQString
mutable QString m_mtmp;
QMakeGlobals *m_option;
QMakeParser *m_parser;

View File

@@ -39,7 +39,7 @@
r == ReturnNext ? "next" : \
r == ReturnReturn ? "return" : \
"<invalid>")
# define dbgKey(s) qPrintable(s.toString().toQString())
# define dbgKey(s) s.toString().toQStringRef().toLocal8Bit().constData()
# define dbgStr(s) qPrintable(formatValue(s, true))
# define dbgStrList(s) qPrintable(formatValueList(s))
# define dbgSepStrList(s) qPrintable(formatValueList(s, true))
@@ -74,6 +74,7 @@ struct QMakeStatics {
QString strhost_build;
ProKey strTEMPLATE;
ProKey strQMAKE_PLATFORM;
ProKey strQMAKE_DIR_SEP;
ProKey strQMAKESPEC;
#ifdef PROEVALUATOR_FULL
ProKey strREQUIRES;

View File

@@ -65,6 +65,7 @@
#endif
QT_BEGIN_NAMESPACE
using namespace QMakeInternal; // for IoUtils
#define fL1S(s) QString::fromLatin1(s)
@@ -93,9 +94,9 @@ QString QMakeGlobals::cleanSpec(QMakeCmdLineParserState &state, const QString &s
{
QString ret = QDir::cleanPath(spec);
if (ret.contains(QLatin1Char('/'))) {
QString absRet = QDir(state.pwd).absoluteFilePath(ret);
QString absRet = IoUtils::resolvePath(state.pwd, ret);
if (QFile::exists(absRet))
ret = QDir::cleanPath(absRet);
ret = absRet;
}
return ret;
}
@@ -108,10 +109,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
QString arg = args.at(*pos);
switch (argState) {
case ArgConfig:
if (state.after)
state.postconfigs << arg;
else
state.preconfigs << arg;
state.configs[state.phase] << arg;
break;
case ArgSpec:
qmakespec = args[*pos] = cleanSpec(state, arg);
@@ -126,20 +124,26 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
user_template_prefix = arg;
break;
case ArgCache:
cachefile = args[*pos] = QDir::cleanPath(QDir(state.pwd).absoluteFilePath(arg));
cachefile = args[*pos] = IoUtils::resolvePath(state.pwd, arg);
break;
case ArgQtConf:
qtconf = args[*pos] = QDir::cleanPath(QDir(state.pwd).absoluteFilePath(arg));
qtconf = args[*pos] = IoUtils::resolvePath(state.pwd, arg);
break;
default:
if (arg.startsWith(QLatin1Char('-'))) {
if (arg == QLatin1String("--")) {
state.extraargs = args.mid(*pos + 1);
*pos = args.size();
args.erase(args.begin() + *pos, args.end());
return ArgumentsOk;
}
if (arg == QLatin1String("-after"))
state.after = true;
if (arg == QLatin1String("-early"))
state.phase = QMakeEvalEarly;
else if (arg == QLatin1String("-before"))
state.phase = QMakeEvalBefore;
else if (arg == QLatin1String("-after"))
state.phase = QMakeEvalAfter;
else if (arg == QLatin1String("-late"))
state.phase = QMakeEvalLate;
else if (arg == QLatin1String("-config"))
argState = ArgConfig;
else if (arg == QLatin1String("-nocache"))
@@ -163,10 +167,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
else
return ArgumentUnknown;
} else if (arg.contains(QLatin1Char('='))) {
if (state.after)
state.postcmds << arg;
else
state.precmds << arg;
state.cmds[state.phase] << arg;
} else {
return ArgumentUnknown;
}
@@ -181,18 +182,17 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state)
{
if (!state.preconfigs.isEmpty())
state.precmds << (fL1S("CONFIG += ") + state.preconfigs.join(QLatin1Char(' ')));
if (!state.extraargs.isEmpty()) {
QString extra = fL1S("QMAKE_EXTRA_ARGS =");
foreach (const QString &ea, state.extraargs)
extra += QLatin1Char(' ') + QMakeEvaluator::quoteValue(ProString(ea));
state.precmds << extra;
state.cmds[QMakeEvalBefore] << extra;
}
for (int p = 0; p < 4; p++) {
if (!state.configs[p].isEmpty())
state.cmds[p] << (fL1S("CONFIG += ") + state.configs[p].join(QLatin1Char(' ')));
extra_cmds[p] = state.cmds[p].join(QLatin1Char('\n'));
}
precmds = state.precmds.join(QLatin1Char('\n'));
if (!state.postconfigs.isEmpty())
state.postcmds << (fL1S("CONFIG += ") + state.postconfigs.join(QLatin1Char(' ')));
postcmds = state.postcmds.join(QLatin1Char('\n'));
if (xqmakespec.isEmpty())
xqmakespec = qmakespec;
@@ -257,11 +257,11 @@ QStringList QMakeGlobals::splitPathList(const QString &val) const
{
QStringList ret;
if (!val.isEmpty()) {
QDir bdir;
QString cwd(QDir::currentPath());
const QStringList vals = val.split(dirlist_sep);
ret.reserve(vals.length());
for (const QString &it : vals)
ret << QDir::cleanPath(bdir.absoluteFilePath(it));
ret << IoUtils::resolvePath(cwd, it);
}
return ret;
}
@@ -316,7 +316,7 @@ bool QMakeGlobals::initProperties()
return false;
data = proc.readAll();
#else
if (FILE *proc = QT_POPEN(QString(QMakeInternal::IoUtils::shellQuote(qmake_abslocation)
if (FILE *proc = QT_POPEN(QString(IoUtils::shellQuote(qmake_abslocation)
+ QLatin1String(" -query")).toLocal8Bit(), QT_POPEN_READ)) {
char buff[1024];
while (!feof(proc))

View File

@@ -46,6 +46,8 @@ QT_BEGIN_NAMESPACE
class QMakeEvaluator;
enum QMakeEvalPhase { QMakeEvalEarly, QMakeEvalBefore, QMakeEvalAfter, QMakeEvalLate };
class QMakeBaseKey
{
public:
@@ -79,12 +81,13 @@ public:
class QMAKE_EXPORT QMakeCmdLineParserState
{
public:
QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), after(false) {}
QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), phase(QMakeEvalBefore) {}
QString pwd;
QStringList precmds, preconfigs, postcmds, postconfigs, extraargs;
bool after;
QStringList cmds[4], configs[4];
QStringList extraargs;
QMakeEvalPhase phase;
void flush() { after = false; }
void flush() { phase = QMakeEvalBefore; }
};
class QMAKE_EXPORT QMakeGlobals
@@ -101,12 +104,12 @@ public:
QProcessEnvironment environment;
#endif
QString qmake_abslocation;
QStringList qmake_args;
QStringList qmake_args, qmake_extra_args;
QString qtconf;
QString qmakespec, xqmakespec;
QString user_template, user_template_prefix;
QString precmds, postcmds;
QString extra_cmds[4];
#ifdef PROEVALUATOR_DEBUG
int debugLevel;
@@ -121,6 +124,7 @@ public:
void setDirectories(const QString &input_dir, const QString &output_dir);
#ifdef QT_BUILD_QMAKE
void setQMakeProperty(QMakeProperty *prop) { property = prop; }
void reloadProperties() { property->reload(); }
ProString propertyValue(const ProKey &name) const { return property->value(name); }
#else
static void parseProperties(const QByteArray &data, QHash<ProKey, ProString> &props);

View File

@@ -49,12 +49,22 @@ ProFileCache::~ProFileCache()
ent.pro->deref();
}
void ProFileCache::discardFile(const QString &fileName)
void ProFileCache::discardFile(const QString &fileName, QMakeVfs *vfs)
{
int eid = vfs->idForFileName(fileName, QMakeVfs::VfsExact | QMakeVfs::VfsAccessedOnly);
if (eid)
discardFile(eid);
int cid = vfs->idForFileName(fileName, QMakeVfs::VfsCumulative | QMakeVfs::VfsAccessedOnly);
if (cid && cid != eid)
discardFile(cid);
}
void ProFileCache::discardFile(int id)
{
#ifdef PROPARSER_THREAD_SAFE
QMutexLocker lck(&mutex);
#endif
QHash<QString, Entry>::Iterator it = parsed_files.find(fileName);
auto it = parsed_files.find(id);
if (it != parsed_files.end()) {
#ifdef PROPARSER_THREAD_SAFE
if (it->locker) {
@@ -74,16 +84,16 @@ void ProFileCache::discardFile(const QString &fileName)
}
}
void ProFileCache::discardFiles(const QString &prefix)
void ProFileCache::discardFiles(const QString &prefix, QMakeVfs *vfs)
{
#ifdef PROPARSER_THREAD_SAFE
QMutexLocker lck(&mutex);
#endif
QHash<QString, Entry>::Iterator
it = parsed_files.begin(),
end = parsed_files.end();
while (it != end)
if (it.key().startsWith(prefix)) {
auto it = parsed_files.begin(), end = parsed_files.end();
while (it != end) {
// Note: this is empty for virtual files from other VFSes.
QString fn = vfs->fileNameForId(it.key());
if (fn.startsWith(prefix)) {
#ifdef PROPARSER_THREAD_SAFE
if (it->locker) {
if (!it->locker->done) {
@@ -103,6 +113,7 @@ void ProFileCache::discardFiles(const QString &prefix)
++it;
}
}
}
////////// Parser ///////////
@@ -115,6 +126,7 @@ static struct {
QString strfor;
QString strdefineTest;
QString strdefineReplace;
QString strbypassNesting;
QString stroption;
QString strreturn;
QString strnext;
@@ -138,6 +150,7 @@ void QMakeParser::initialize()
statics.strfor = QLatin1String("for");
statics.strdefineTest = QLatin1String("defineTest");
statics.strdefineReplace = QLatin1String("defineReplace");
statics.strbypassNesting = QLatin1String("bypassNesting");
statics.stroption = QLatin1String("option");
statics.strreturn = QLatin1String("return");
statics.strnext = QLatin1String("next");
@@ -162,18 +175,15 @@ QMakeParser::QMakeParser(ProFileCache *cache, QMakeVfs *vfs, QMakeParserHandler
ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
{
ProFile *pro;
if ((flags & (ParseUseCache|ParseOnlyCached)) && m_cache) {
QMakeVfs::VfsFlags vfsFlags = ((flags & ParseCumulative) ? QMakeVfs::VfsCumulative
: QMakeVfs::VfsExact);
int id = m_vfs->idForFileName(fileName, vfsFlags);
if ((flags & ParseUseCache) && m_cache) {
ProFileCache::Entry *ent;
#ifdef PROPARSER_THREAD_SAFE
QMutexLocker locker(&m_cache->mutex);
#endif
QHash<QString, ProFileCache::Entry>::Iterator it;
#ifdef PROEVALUATOR_DUAL_VFS
QString virtFileName = ((flags & ParseCumulative) ? '-' : '+') + fileName;
it = m_cache->parsed_files.find(virtFileName);
if (it == m_cache->parsed_files.end())
#endif
it = m_cache->parsed_files.find(fileName);
auto it = m_cache->parsed_files.find(id);
if (it != m_cache->parsed_files.end()) {
ent = &*it;
#ifdef PROPARSER_THREAD_SAFE
@@ -190,24 +200,15 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
#endif
if ((pro = ent->pro))
pro->ref();
} else if (!(flags & ParseOnlyCached)) {
QString contents;
QMakeVfs::VfsFlags vfsFlags =
((flags & ParseCumulative) ? QMakeVfs::VfsCumulative : QMakeVfs::VfsExact);
bool virt = false;
#ifdef PROEVALUATOR_DUAL_VFS
virt = m_vfs->readVirtualFile(fileName, vfsFlags, &contents);
if (virt)
ent = &m_cache->parsed_files[virtFileName];
else
#endif
ent = &m_cache->parsed_files[fileName];
} else {
ent = &m_cache->parsed_files[id];
#ifdef PROPARSER_THREAD_SAFE
ent->locker = new ProFileCache::Entry::Locker;
locker.unlock();
#endif
if (virt || readFile(fileName, vfsFlags | QMakeVfs::VfsNoVirtual, flags, &contents)) {
pro = parsedProBlock(QStringRef(&contents), fileName, 1, FullGrammar);
QString contents;
if (readFile(id, flags, &contents)) {
pro = parsedProBlock(QStringRef(&contents), id, fileName, 1, FullGrammar);
pro->itemsRef()->squeeze();
pro->ref();
} else {
@@ -224,46 +225,39 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
ent->locker = 0;
}
#endif
} else {
pro = 0;
}
} else if (!(flags & ParseOnlyCached)) {
QString contents;
QMakeVfs::VfsFlags vfsFlags =
((flags & ParseCumulative) ? QMakeVfs::VfsCumulative : QMakeVfs::VfsExact);
if (readFile(fileName, vfsFlags, flags, &contents))
pro = parsedProBlock(QStringRef(&contents), fileName, 1, FullGrammar);
else
pro = 0;
} else {
QString contents;
if (readFile(id, flags, &contents))
pro = parsedProBlock(QStringRef(&contents), id, fileName, 1, FullGrammar);
else
pro = 0;
}
return pro;
}
ProFile *QMakeParser::parsedProBlock(
const QStringRef &contents, const QString &name, int line, SubGrammar grammar)
const QStringRef &contents, int id, const QString &name, int line, SubGrammar grammar)
{
ProFile *pro = new ProFile(name);
ProFile *pro = new ProFile(id, name);
read(pro, contents, line, grammar);
return pro;
}
void QMakeParser::discardFileFromCache(const QString &fileName)
void QMakeParser::discardFileFromCache(int id)
{
if (m_cache)
m_cache->discardFile(fileName);
m_cache->discardFile(id);
}
bool QMakeParser::readFile(
const QString &fn, QMakeVfs::VfsFlags vfsFlags, ParseFlags flags, QString *contents)
bool QMakeParser::readFile(int id, ParseFlags flags, QString *contents)
{
QString errStr;
QMakeVfs::ReadResult result = m_vfs->readFile(fn, vfsFlags, contents, &errStr);
QMakeVfs::ReadResult result = m_vfs->readFile(id, contents, &errStr);
if (result != QMakeVfs::ReadOk) {
if (m_handler && ((flags & ParseReportMissing) || result != QMakeVfs::ReadNotFound))
m_handler->message(QMakeParserHandler::ParserIoError,
fL1S("Cannot read %1: %2").arg(fn, errStr));
fL1S("Cannot read %1: %2").arg(m_vfs->fileNameForId(id), errStr));
return false;
}
return true;
@@ -1171,6 +1165,25 @@ void QMakeParser::finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int arg
}
parseError(fL1S("%1(function) requires one literal argument.").arg(*defName));
return;
} else if (m_tmp == statics.strbypassNesting) {
if (*uce != TokFuncTerminator) {
bogusTest(tokPtr, fL1S("%1() requires zero arguments.").arg(m_tmp));
return;
}
if (!(m_blockstack.top().nest & NestFunction)) {
bogusTest(tokPtr, fL1S("Unexpected %1().").arg(m_tmp));
return;
}
if (m_invert) {
bogusTest(tokPtr, fL1S("Unexpected NOT operator in front of %1().").arg(m_tmp));
return;
}
flushScopes(tokPtr);
putLineMarker(tokPtr);
putOperator(tokPtr);
putTok(tokPtr, TokBypassNesting);
enterScope(tokPtr, true, StCtrl);
return;
} else if (m_tmp == statics.strreturn) {
if (m_blockstack.top().nest & NestFunction) {
if (argc > 1) {
@@ -1439,7 +1452,7 @@ static bool getBlock(const ushort *tokens, int limit, int &offset, QString *outS
"TokReturn", "TokBreak", "TokNext",
"TokNot", "TokAnd", "TokOr",
"TokBranch", "TokForLoop",
"TokTestDef", "TokReplaceDef"
"TokTestDef", "TokReplaceDef", "TokBypassNesting"
};
while (offset != limit) {
@@ -1523,6 +1536,9 @@ static bool getBlock(const ushort *tokens, int limit, int &offset, QString *outS
if (ok)
ok = getSubBlock(tokens, limit, offset, outStr, indent, "body");
break;
case TokBypassNesting:
ok = getSubBlock(tokens, limit, offset, outStr, indent, "block");
break;
default:
Q_ASSERT(!"unhandled token");
}

View File

@@ -75,7 +75,6 @@ public:
enum ParseFlag {
ParseDefault = 0,
ParseUseCache = 1,
ParseOnlyCached = 2,
ParseReportMissing = 4,
#ifdef PROEVALUATOR_DUAL_VFS
ParseCumulative = 8
@@ -90,10 +89,10 @@ public:
enum SubGrammar { FullGrammar, TestGrammar, ValueGrammar };
// fileName is expected to be absolute and cleanPath()ed.
ProFile *parsedProFile(const QString &fileName, ParseFlags flags = ParseDefault);
ProFile *parsedProBlock(const QStringRef &contents, const QString &name, int line = 0,
ProFile *parsedProBlock(const QStringRef &contents, int id, const QString &name, int line = 0,
SubGrammar grammar = FullGrammar);
void discardFileFromCache(const QString &fileName);
void discardFileFromCache(int id);
#ifdef PROPARSER_DEBUG
static QString formatProBlock(const QString &block);
@@ -132,7 +131,7 @@ private:
ushort terminator; // '}' if replace function call is braced, ':' if test function
};
bool readFile(const QString &fn, QMakeVfs::VfsFlags vfsFlags, QMakeParser::ParseFlags flags, QString *contents);
bool readFile(int id, QMakeParser::ParseFlags flags, QString *contents);
void read(ProFile *pro, const QStringRef &content, int line, SubGrammar grammar);
ALWAYS_INLINE void putTok(ushort *&tokPtr, ushort tok);
@@ -201,8 +200,9 @@ public:
ProFileCache() {}
~ProFileCache();
void discardFile(const QString &fileName);
void discardFiles(const QString &prefix);
void discardFile(int id);
void discardFile(const QString &fileName, QMakeVfs *vfs);
void discardFiles(const QString &prefix, QMakeVfs *vfs);
private:
struct Entry {
@@ -218,7 +218,7 @@ private:
#endif
};
QHash<QString, Entry> parsed_files;
QHash<int, Entry> parsed_files;
#ifdef PROPARSER_THREAD_SAFE
QMutex mutex;
#endif

View File

@@ -51,19 +51,85 @@ QMakeVfs::QMakeVfs()
#endif
}
bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, VfsFlags flags,
#ifdef PROPARSER_THREAD_SAFE
QMutex QMakeVfs::s_mutex;
#endif
QAtomicInt QMakeVfs::s_fileIdCounter;
QHash<QString, int> QMakeVfs::s_fileIdMap;
QHash<int, QString> QMakeVfs::s_idFileMap;
int QMakeVfs::idForFileName(const QString &fn, VfsFlags flags)
{
#ifdef PROEVALUATOR_DUAL_VFS
{
# ifdef PROPARSER_THREAD_SAFE
QMutexLocker locker(&m_vmutex);
# endif
int idx = (flags & VfsCumulative) ? 1 : 0;
if (flags & VfsCreate) {
int &id = m_virtualFileIdMap[idx][fn];
if (!id) {
id = ++s_fileIdCounter;
m_virtualIdFileMap[id] = fn;
}
return id;
}
int id = m_virtualFileIdMap[idx].value(fn);
if (id || (flags & VfsCreatedOnly))
return id;
}
#endif
if (!(flags & VfsAccessedOnly)) {
#ifdef PROPARSER_THREAD_SAFE
QMutexLocker locker(&s_mutex);
#endif
int &id = s_fileIdMap[fn];
if (!id) {
id = ++s_fileIdCounter;
s_idFileMap[id] = fn;
}
return id;
}
return s_fileIdMap.value(fn);
}
QString QMakeVfs::fileNameForId(int id)
{
#ifdef PROEVALUATOR_DUAL_VFS
{
# ifdef PROPARSER_THREAD_SAFE
QMutexLocker locker(&m_vmutex);
# endif
const QString &fn = m_virtualIdFileMap.value(id);
if (!fn.isEmpty())
return fn;
}
#endif
#ifdef PROPARSER_THREAD_SAFE
QMutexLocker locker(&s_mutex);
#endif
return s_idFileMap.value(id);
}
void QMakeVfs::clearIds()
{
#ifdef PROEVALUATOR_THREAD_SAFE
QMutexLocker locker(&s_mutex);
#endif
s_fileIdCounter = 0;
s_fileIdMap.clear();
s_idFileMap.clear();
}
bool QMakeVfs::writeFile(int id, QIODevice::OpenMode mode, VfsFlags flags,
const QString &contents, QString *errStr)
{
#ifndef PROEVALUATOR_FULL
# ifdef PROEVALUATOR_THREAD_SAFE
QMutexLocker locker(&m_mutex);
# endif
#ifdef PROEVALUATOR_DUAL_VFS
QString *cont = &m_files[((flags & VfsCumulative) ? '-' : '+') + fn];
#else
QString *cont = &m_files[fn];
QString *cont = &m_files[id];
Q_UNUSED(flags)
#endif
if (mode & QIODevice::Append)
*cont += contents;
else
@@ -71,13 +137,13 @@ bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, VfsFlags f
Q_UNUSED(errStr)
return true;
#else
QFileInfo qfi(fn);
QFileInfo qfi(fileNameForId(id));
if (!QDir::current().mkpath(qfi.path())) {
*errStr = fL1S("Cannot create parent directory");
return false;
}
QByteArray bytes = contents.toLocal8Bit();
QFile cfile(fn);
QFile cfile(qfi.filePath());
if (!(mode & QIODevice::Append) && cfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (cfile.readAll() == bytes) {
if (flags & VfsExecutable) {
@@ -108,53 +174,13 @@ bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, VfsFlags f
#endif
}
#ifndef PROEVALUATOR_FULL
bool QMakeVfs::readVirtualFile(const QString &fn, VfsFlags flags, QString *contents)
{
# ifdef PROEVALUATOR_THREAD_SAFE
QMutexLocker locker(&m_mutex);
# endif
QHash<QString, QString>::ConstIterator it;
# ifdef PROEVALUATOR_DUAL_VFS
it = m_files.constFind(((flags & VfsCumulative) ? '-' : '+') + fn);
if (it != m_files.constEnd()) {
*contents = *it;
return true;
}
# else
it = m_files.constFind(fn);
if (it != m_files.constEnd()
&& it->constData() != m_magicMissing.constData()
&& it->constData() != m_magicExisting.constData()) {
*contents = *it;
return true;
}
Q_UNUSED(flags)
# endif
return false;
}
#endif
QMakeVfs::ReadResult QMakeVfs::readFile(
const QString &fn, VfsFlags flags, QString *contents, QString *errStr)
QMakeVfs::ReadResult QMakeVfs::readFile(int id, QString *contents, QString *errStr)
{
#ifndef PROEVALUATOR_FULL
# ifdef PROEVALUATOR_THREAD_SAFE
QMutexLocker locker(&m_mutex);
# endif
QHash<QString, QString>::ConstIterator it;
# ifdef PROEVALUATOR_DUAL_VFS
if (!(flags & VfsNoVirtual)) {
it = m_files.constFind(((flags & VfsCumulative) ? '-' : '+') + fn);
if (it != m_files.constEnd()) {
*contents = *it;
return ReadOk;
}
}
# else
Q_UNUSED(flags)
# endif
it = m_files.constFind(fn);
auto it = m_files.constFind(id);
if (it != m_files.constEnd()) {
if (it->constData() == m_magicMissing.constData()) {
*errStr = fL1S("No such file or directory");
@@ -165,15 +191,13 @@ QMakeVfs::ReadResult QMakeVfs::readFile(
return ReadOk;
}
}
#else
Q_UNUSED(flags)
#endif
QFile file(fn);
QFile file(fileNameForId(id));
if (!file.open(QIODevice::ReadOnly)) {
if (!file.exists()) {
#ifndef PROEVALUATOR_FULL
m_files[fn] = m_magicMissing;
m_files[id] = m_magicMissing;
#endif
*errStr = fL1S("No such file or directory");
return ReadNotFound;
@@ -182,7 +206,7 @@ QMakeVfs::ReadResult QMakeVfs::readFile(
return ReadOtherError;
}
#ifndef PROEVALUATOR_FULL
m_files[fn] = m_magicExisting;
m_files[id] = m_magicExisting;
#endif
QByteArray bcont = file.readAll();
@@ -205,15 +229,8 @@ bool QMakeVfs::exists(const QString &fn, VfsFlags flags)
# ifdef PROEVALUATOR_THREAD_SAFE
QMutexLocker locker(&m_mutex);
# endif
QHash<QString, QString>::ConstIterator it;
# ifdef PROEVALUATOR_DUAL_VFS
it = m_files.constFind(((flags & VfsCumulative) ? '-' : '+') + fn);
if (it != m_files.constEnd())
return true;
# else
Q_UNUSED(flags)
# endif
it = m_files.constFind(fn);
int id = idForFileName(fn, flags);
auto it = m_files.constFind(id);
if (it != m_files.constEnd())
return it->constData() != m_magicMissing.constData();
#else
@@ -221,7 +238,7 @@ bool QMakeVfs::exists(const QString &fn, VfsFlags flags)
#endif
bool ex = IoUtils::fileType(fn) == IoUtils::FileIsRegular;
#ifndef PROEVALUATOR_FULL
m_files[fn] = ex ? m_magicExisting : m_magicMissing;
m_files[id] = ex ? m_magicExisting : m_magicMissing;
#endif
return ex;
}
@@ -233,7 +250,7 @@ void QMakeVfs::invalidateCache()
# ifdef PROEVALUATOR_THREAD_SAFE
QMutexLocker locker(&m_mutex);
# endif
QHash<QString, QString>::Iterator it = m_files.begin(), eit = m_files.end();
auto it = m_files.begin(), eit = m_files.end();
while (it != eit) {
if (it->constData() == m_magicMissing.constData()
||it->constData() == m_magicExisting.constData())

View File

@@ -28,13 +28,11 @@
#include "qmake_global.h"
#include <qiodevice.h>
#ifndef PROEVALUATOR_FULL
#include <qhash.h>
#include <qstring.h>
#ifdef PROEVALUATOR_THREAD_SAFE
# include <qmutex.h>
#endif
#endif
#ifndef QT_NO_TEXTCODEC
QT_FORWARD_DECLARE_CLASS(QTextCodec)
@@ -62,23 +60,27 @@ public:
VfsExact = 0,
#ifdef PROEVALUATOR_DUAL_VFS
VfsCumulative = 2,
VfsNoVirtual = 4
VfsCreate = 4,
VfsCreatedOnly = 8,
#else
VfsCumulative = 0,
VfsNoVirtual = 0
VfsCreate = 0,
VfsCreatedOnly = 0,
#endif
VfsAccessedOnly = 16
};
Q_DECLARE_FLAGS(VfsFlags, VfsFlag)
QMakeVfs();
bool writeFile(const QString &fn, QIODevice::OpenMode mode, VfsFlags flags, const QString &contents, QString *errStr);
ReadResult readFile(const QString &fn, VfsFlags flags, QString *contents, QString *errStr);
bool exists(const QString &fn, VfsFlags flags);
int idForFileName(const QString &fn, VfsFlags flags);
QString fileNameForId(int id);
static void clearIds();
bool writeFile(int id, QIODevice::OpenMode mode, VfsFlags flags, const QString &contents, QString *errStr);
ReadResult readFile(int id, QString *contents, QString *errStr);
bool exists(const QString &fn, QMakeVfs::VfsFlags flags);
#ifndef PROEVALUATOR_FULL
bool readVirtualFile(const QString &fn, VfsFlags flags, QString *contents);
void invalidateCache();
void invalidateContents();
#endif
@@ -88,11 +90,34 @@ public:
#endif
private:
#ifdef PROEVALUATOR_THREAD_SAFE
static QMutex s_mutex;
#endif
static QAtomicInt s_fileIdCounter;
// Qt Creator's ProFile cache is a singleton to maximize its cross-project
// effectiveness (shared prf files from QtVersions).
// For this to actually work, real files need a global mapping.
// This is fine, because the namespace of real files is indeed global.
static QHash<QString, int> s_fileIdMap;
static QHash<int, QString> s_idFileMap;
#ifdef PROEVALUATOR_DUAL_VFS
# ifdef PROEVALUATOR_THREAD_SAFE
// The simple way to avoid recursing m_mutex.
QMutex m_vmutex;
# endif
// Virtual files are bound to the project context they were created in,
// so their ids need to be local as well.
// We violate that rule in lupdate (which has a non-dual VFS), but that
// does not matter, because it has only one project context anyway.
QHash<QString, int> m_virtualFileIdMap[2]; // Exact and cumulative
QHash<int, QString> m_virtualIdFileMap; // Only one map, as ids are unique across realms.
#endif
#ifndef PROEVALUATOR_FULL
# ifdef PROEVALUATOR_THREAD_SAFE
QMutex m_mutex;
# endif
QHash<QString, QString> m_files;
QHash<int, QString> m_files;
QString m_magicMissing;
QString m_magicExisting;
#endif

View File

@@ -25,4 +25,5 @@ QtcAutotest {
files: "tst_profilewriter.cpp"
}
cpp.includePaths: base.concat([proParserGroup.prefix])
cpp.defines: base.concat("QT_USE_FAST_OPERATOR_PLUS")
}

View File

@@ -448,7 +448,7 @@ void tst_ProFileWriter::adds()
QMakeVfs vfs;
QMakeParser parser(0, &vfs, &parseHandler);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), QLatin1String(BASE_DIR "/test.pro"), 1);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), 0, QLatin1String(BASE_DIR "/test.pro"), 1);
QVERIFY(proFile);
PW::putVarValues(proFile, &lines, values, var, PW::PutFlags(flags), scope);
proFile->deref();
@@ -619,7 +619,7 @@ void tst_ProFileWriter::removes()
QMakeVfs vfs;
QMakeParser parser(0, &vfs, &parseHandler);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), QLatin1String(BASE_DIR "/test.pro"), 1);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), 0, QLatin1String(BASE_DIR "/test.pro"), 1);
QVERIFY(proFile);
QmakeProjectManager::Internal::ProWriter::removeVarValues(proFile, &lines, values, vars);
proFile->deref();
@@ -648,7 +648,7 @@ void tst_ProFileWriter::multiVar()
QMakeVfs vfs;
QMakeParser parser(0, &vfs, &parseHandler);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), QLatin1String(BASE_DIR "/test.pro"), 1);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), 0, QLatin1String(BASE_DIR "/test.pro"), 1);
QVERIFY(proFile);
QmakeProjectManager::Internal::ProWriter::removeFiles(proFile, &lines, baseDir, files, vars);
proFile->deref();
@@ -669,7 +669,7 @@ void tst_ProFileWriter::addFiles()
QMakeVfs vfs;
QMakeParser parser(0, &vfs, &parseHandler);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), QLatin1String(BASE_DIR "/test.pro"), 1);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), 0, QLatin1String(BASE_DIR "/test.pro"), 1);
QVERIFY(proFile);
QmakeProjectManager::Internal::ProWriter::addFiles(proFile, &lines,
QStringList() << QString::fromLatin1(BASE_DIR "/sub/bar.cpp"),
@@ -691,7 +691,7 @@ void tst_ProFileWriter::removeFiles()
QMakeVfs vfs;
QMakeParser parser(0, &vfs, &parseHandler);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), QLatin1String(BASE_DIR "/test.pro"), 1);
ProFile *proFile = parser.parsedProBlock(QStringRef(&input), 0, QLatin1String(BASE_DIR "/test.pro"), 1);
QVERIFY(proFile);
QmakeProjectManager::Internal::ProWriter::removeFiles(proFile, &lines, QDir(BASE_DIR),
QStringList() << QString::fromLatin1(BASE_DIR "/sub/bar.cpp"),

View File

@@ -255,18 +255,9 @@ class JIRA:
# for later lookup which function to call for which bug
# ALWAYS update this dict when adding a new function for a workaround!
def __initBugDict__(self):
self.__bugs__= {
'QTCREATORBUG-19717':self._workaroundCreator19717_,
}
self.__bugs__= {}
# helper function - will be called if no workaround for the requested bug is deposited
def _exitFatal_(self, bugType, number):
test.fatal("No workaround found for bug %s-%d" % (bugType, number))
############### functions that hold workarounds #################################
def _workaroundCreator19717_(self, *args):
targetname = Targets.getStringForTarget(Targets.DESKTOP_5_3_1_DEFAULT)
switchViewTo(ViewConstants.PROJECTS)
mouseClick(waitForObjectItem(":Projects.ProjectNavigationTreeView",
"Build & Run." + targetname.replace(".", "\\.")))
switchViewTo(ViewConstants.EDIT)

View File

@@ -124,8 +124,6 @@ def main():
if not startedWithoutPluginError():
return
JIRA.performWorkaroundForBug(19717)
# if Debug is enabled - 1 valid kit is assigned - real check for this is done in tst_qml_locals
fancyDebugButton = waitForObject(":*Qt Creator.Start Debugging_Core::Internal::FancyToolButton")
if test.verify(waitFor('fancyDebugButton.enabled', 5000), "Start Debugging is enabled."):

View File

@@ -43,7 +43,6 @@ def main():
startApplication('qtcreator' + SettingsPath + ' "%s"' % qmlProjFile)
if not startedWithoutPluginError():
return
JIRA.performWorkaroundForBug(19717)
waitFor('object.exists(":Qt Creator_Utils::NavigationTreeView")', 10000)
fancyConfButton = findObject(":*Qt Creator_Core::Internal::FancyToolButton")
fancyRunButton = findObject(":*Qt Creator.Run_Core::Internal::FancyToolButton")

View File

@@ -25,10 +25,12 @@
source("../../shared/qtcreator.py")
focusDocumentPath = "keyinteraction.Resources.keyinteraction\.qrc./keyinteraction.focus.%s"
def main():
target = Targets.DESKTOP_5_3_1_DEFAULT
sourceExample = os.path.join(Qt5Path.examplesPath(target), "declarative/keyinteraction/focus")
proFile = "focus.pro"
target = Targets.DESKTOP_5_6_1_DEFAULT
sourceExample = os.path.join(Qt5Path.examplesPath(target), "quick/keyinteraction")
proFile = "keyinteraction.pro"
if not neededFilePresent(os.path.join(sourceExample, proFile)):
return
startApplication("qtcreator" + SettingsPath)
@@ -36,9 +38,9 @@ def main():
return
# add docs to have the correct tool tips
addHelpDocumentation([os.path.join(Qt5Path.docsPath(target), "qtquick.qch")])
templateDir = prepareTemplate(sourceExample, "/../../helper")
templateDir = prepareTemplate(sourceExample)
openQmakeProject(os.path.join(templateDir, proFile), [target])
openDocument("focus.QML.qml" + os.sep + "focus.focus\\.qml")
openDocument(focusDocumentPath % "focus\\.qml")
testRenameId()
testFindUsages()
testHovering()
@@ -47,20 +49,20 @@ def main():
def testRenameId():
test.log("Testing rename of id")
files = ["FocusCore.ContextMenu\\.qml", "FocusCore.GridMenu\\.qml",
"FocusCore.ListMenu\\.qml", "focus\\.qml"]
files = ["Core.ContextMenu\\.qml", "Core.GridMenu\\.qml",
"Core.ListMenu\\.qml", "focus\\.qml"]
originalTexts = {}
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
formerTxt = editor.plainText
for file in files:
openDocument("focus.QML.qml" + os.sep + "focus.%s" % file)
openDocument(focusDocumentPath % file)
# wait until editor content switched to the double-clicked file
while formerTxt==editor.plainText:
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# store content for next round
formerTxt = editor.plainText
originalTexts.setdefault(file, "%s" % formerTxt)
test.log("stored %s's content" % file.replace("FocusCore.","").replace("\\",""))
test.log("stored %s's content" % file.replace("Core.","").replace("\\",""))
# last opened file is the main file focus.qml
line = "FocusScope\s*\{"
if not placeCursorToLine(editor, line, True):
@@ -77,18 +79,18 @@ def testRenameId():
# store editor content for synchronizing purpose
formerTxt = editor.plainText
for file in files:
openDocument("focus.QML.qml" + os.sep + "focus.%s" % file)
openDocument(focusDocumentPath % file)
# wait until editor content switched to double-clicked file
while formerTxt==editor.plainText:
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
# store content for next round
formerTxt = editor.plainText
originalText = originalTexts.get(file).replace("mainView", "renamedView")
test.compare(originalText,formerTxt, "Comparing %s" % file.replace("FocusCore.","").replace("\\",""))
test.compare(originalText,formerTxt, "Comparing %s" % file.replace("Core.","").replace("\\",""))
invokeMenuItem("File","Save All")
def __invokeFindUsage__(filename, line, additionalKeyPresses, expectedCount):
openDocument("focus.QML.qml" + os.sep + "focus.%s" % filename)
openDocument(focusDocumentPath % filename)
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
if not placeCursorToLine(editor, line, True):
test.fatal("File seems to have changed... Canceling current test")
@@ -101,17 +103,18 @@ def __invokeFindUsage__(filename, line, additionalKeyPresses, expectedCount):
def testFindUsages():
test.log("Testing find usage of an ID")
__invokeFindUsage__("focus\\.qml", "FocusScope\s*\{", ["<Down>"], 6)
__invokeFindUsage__("focus\\.qml", "FocusScope\s*\{", ["<Down>"], 7)
test.log("Testing find usage of a property")
clickButton(waitForObject(":*Qt Creator.Clear_QToolButton"))
home = "<Home>"
if platform.system() == "Darwin":
home = "<Ctrl+Left>"
__invokeFindUsage__("focus\\.qml", "id: window", ["<Down>", "<Down>", home], 26)
__invokeFindUsage__("focus\\.qml", "id: window", ["<Down>", "<Down>", home],
29 if JIRA.isBugStillOpen(19915) else 30)
def testHovering():
test.log("Testing hovering elements")
openDocument("focus.QML.qml" + os.sep + "focus.focus\\.qml")
openDocument(focusDocumentPath % "focus\\.qml")
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
lines=["FocusScope\s*\{", "Rectangle\s*\{"]
if platform.system() == "Darwin":
@@ -129,7 +132,7 @@ def testHovering():
alternativeValues = [{"text":"FocusScope"}, {"text":"Rectangle"}]
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
test.log("Testing hovering properties")
openDocument("focus.QML.qml" + os.sep + "focus.focus\\.qml")
openDocument(focusDocumentPath % "focus\\.qml")
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
lines = ['focus:\s*true', 'color:\s*"black"', 'states:\s*State\s*\{', 'transitions:\s*Transition\s*\{']
expectedTypes = ["TextTip", "TextTip", "TextTip", "TextTip"]
@@ -141,15 +144,19 @@ def testHovering():
'></td></tr></table>'},
{'text':'<table><tr><td valign=middle>string<p>This property holds the color used to fill the rectangle.'
'</p></td><td>&nbsp;&nbsp;<img src=":/utils/tooltip/images/f1.png"></td></tr></table>'},
{'text':'<table><tr><td valign=middle>State<p>This property holds a list of states defined by the item.'
{'text':'<table><tr><td valign=middle>State<p>This property holds the list of possible states for this item. '
'To change the state of this item, set the state property to one of these states, or set the state property '
'to an empty string to revert the item to its default state.'
'</p></td><td>&nbsp;&nbsp;<img src=":/utils/tooltip/images/f1.png"></td></tr></table>'},
{'text':'<table><tr><td valign=middle>Transition<p>This property holds a list of transitions defined by '
'the item.</p></td><td>&nbsp;&nbsp;<img src=":/utils/tooltip/images/f1.png"></td></tr></table>'}
{'text':'<table><tr><td valign=middle>Transition<p>This property holds the list of transitions for this item. '
'These define the transitions to be applied to the item whenever it changes its state.'
'</p></td><td>&nbsp;&nbsp;<img src=":/utils/tooltip/images/f1.png"></td></tr></table>'}
]
alternativeValues = [{"text":"boolean"}, {"text":"string"}, {"text":"State"}, {"text":"Transition"}]
alternativeValues = [{"text":"Rectangle" if JIRA.isBugStillOpen(20020) else "boolean"},
{"text":"string"}, {"text":"State"}, {"text":"Transition"}]
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
test.log("Testing hovering expressions")
openDocument("focus.QML.qml" + os.sep + "focus.focus\\.qml")
openDocument(focusDocumentPath % "focus\\.qml")
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
lines=['color:\s*"black"', 'color:\s*"#3E606F"']
additionalKeyPresses = ["<Left>"]
@@ -157,7 +164,7 @@ def testHovering():
alternativeValues = [None, "#39616B"]
expectedTypes = ["ColorTip", "ColorTip"]
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
openDocument("focus.QML.qml" + os.sep + "focus.FocusCore.ListMenu\\.qml")
openDocument(focusDocumentPath % "Core.ListMenu\\.qml")
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
lines=['Rectangle\s*\{.*color:\s*"#D1DBBD"', 'NumberAnimation\s*\{\s*.*Easing.OutQuint\s*\}']
additionalKeyPresses = ["<Left>", "<Left>", "<Left>", "<Left>"]

View File

@@ -26,8 +26,7 @@
source("../../shared/qtcreator.py")
def main():
if platform.system() == 'Darwin':
test.warning("This needs a Qt 5.4 kit. Skipping it.")
test.warning("This needs a Qt 5.6.2 kit. Skipping it.")
return
pathCreator = os.path.join(srcPath, "creator", "qtcreator.qbs")
if not neededFilePresent(pathCreator):

View File

@@ -101,8 +101,12 @@ def renameFile(projectDir, proFile, branch, oldname, newname):
else:
menu = ":Qt Creator.Project.Menu.File_QMenu"
activateItem(waitForObjectItem(menu, "Rename..."))
type(waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit"), newname)
type(waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit"), "<Return>")
replaceEdit = waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit")
if not (oldname.lower().endswith(".qrc") and JIRA.isBugStillOpen(20057)):
test.compare(replaceEdit.selectedText, oldname.rsplit(".", 1)[0],
"Only the filename without the extension is selected?")
replaceEditorContent(replaceEdit, newname)
type(replaceEdit, "<Return>")
test.verify(waitFor("os.path.exists(newFilePath)", 1000),
"Verify that file with new name exists: %s" % newFilePath)
test.compare(readFile(newFilePath), oldFileText,

View File

@@ -42,7 +42,7 @@ def main():
test.fatal("Failed to activate kit %s" % kit)
continue
test.log("Running project Qt Quick UI Prototype (%s)" % kit)
qmlViewer = modifyRunSettingsForHookIntoQtQuickUI(1, 0, workingDir, projectName, 11223, quick)
qmlViewer = modifyRunSettingsForHookIntoQtQuickUI(2, 1, workingDir, projectName, 11223, quick)
if qmlViewer!=None:
qmlViewerPath = os.path.dirname(qmlViewer)
qmlViewer = os.path.basename(qmlViewer)