Merge remote-tracking branch 'origin/4.14'

Conflicts:
	src/plugins/mesonprojectmanager/project/mesonprojectparser.h

Change-Id: Id38d20ce20981dcdc322fe5d1d7647f4bec89d8a
This commit is contained in:
Eike Ziller
2020-11-13 16:03:26 +01:00
125 changed files with 1246 additions and 847 deletions

View File

@@ -39,7 +39,6 @@
#include <QVector>
#include <QHash>
#include <QMap>
#include <QFutureInterface>
#include <QVersionNumber>
#include <utils/fileutils.h>

View File

@@ -31,7 +31,6 @@
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <qmldebug/qmloutputparser.h>
#include <QFutureInterface>
#include <QObject>
#include <QTimer>
#include <QTcpSocket>

View File

@@ -234,8 +234,9 @@ void AvdDialog::updateApiLevelComboBox()
m_avdDialog.targetApiComboBox->clear();
for (SystemImage *image : filteredList) {
QString imageString = "android-" % QString::number(image->apiLevel());
if (image->sdkStylePath().contains("playstore"))
imageString += " (Google PlayStore)";
const QStringList imageSplits = image->sdkStylePath().split(';');
if (imageSplits.size() == 4)
imageString += QStringLiteral(" (%1)").arg(imageSplits.at(2));
m_avdDialog.targetApiComboBox->addItem(imageString,
QVariant::fromValue<SystemImage *>(image));
m_avdDialog.targetApiComboBox->setItemData(m_avdDialog.targetApiComboBox->count() - 1,

View File

@@ -60,7 +60,6 @@
#include <QDir>
#include <QFileInfo>
#include <QFutureWatcher>
#include <QMenu>
#include <QPlainTextEdit>
#include <QProcess>

View File

@@ -1,5 +1,5 @@
add_qtc_plugin(ClangFormat
CONDITION TARGET libclang
CONDITION TARGET libclang AND LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 10.0.0
DEPENDS Utils Qt5::Widgets clangFormat
INCLUDES "${CLANG_INCLUDE_DIRS}"
PLUGIN_DEPENDS Core TextEditor CppEditor CppTools ProjectExplorer

View File

@@ -115,7 +115,7 @@ static clang::format::FormatStyle qtcStyle()
style.ExperimentalAutoDetectBinPacking = false;
style.FixNamespaceComments = true;
style.ForEachMacros = {"forever", "foreach", "Q_FOREACH", "BOOST_FOREACH"};
style.IncludeStyle.IncludeCategories = {{"^<Q.*", 200}};
style.IncludeStyle.IncludeCategories = {{"^<Q.*", 200, 200}};
style.IncludeStyle.IncludeIsMainRegex = "(Test)?$";
style.IndentCaseLabels = false;
style.IndentWidth = 4;

View File

@@ -27,11 +27,10 @@
#include <coreplugin/find/ifindfilter.h>
#include <QFutureWatcher>
#include <QPointer>
#include <QWidget>
#include <QCheckBox>
#include <QPointer>
#include <QRadioButton>
#include <QWidget>
namespace Core { class SearchResult; }

View File

@@ -76,7 +76,7 @@ public:
int filesAnalyzed() const { return m_filesAnalyzed.size(); }
int filesNotAnalyzed() const { return m_filesNotAnalyzed.size(); }
int totalFilesToAnalyze() const { return m_fileInfos.size(); }
int totalFilesToAnalyze() const { return int(m_fileInfos.size()); }
signals:
void buildFailed();

View File

@@ -387,7 +387,7 @@ void ShortcutSettingsWidget::setupShortcutBox(ShortcutItem *scitem)
};
const auto addButtonToLayout = [this, updateAddButton] {
m_shortcutLayout->addWidget(m_addButton,
m_shortcutInputs.size() * 2 - 1,
int(m_shortcutInputs.size() * 2 - 1),
m_shortcutLayout->columnCount() - 1);
updateAddButton();
};
@@ -397,7 +397,7 @@ void ShortcutSettingsWidget::setupShortcutBox(ShortcutItem *scitem)
for (int i = 0; i < qMax(1, scitem->m_keys.size()); ++i)
addShortcutInput(i, scitem->m_keys.value(i));
connect(m_addButton, &QPushButton::clicked, this, [this, addShortcutInput, addButtonToLayout] {
addShortcutInput(m_shortcutInputs.size(), {});
addShortcutInput(int(m_shortcutInputs.size()), {});
addButtonToLayout();
});
addButtonToLayout();

View File

@@ -27,7 +27,7 @@
#include <cppcheck/cppcheckoptions.h>
#include <QFuture>
#include <QFutureInterface>
#include <QPointer>
#include <QRegularExpression>

View File

@@ -91,7 +91,6 @@
#include <QAction>
#include <QApplication>
#include <QElapsedTimer>
#include <QFutureWatcher>
#include <QMenu>
#include <QPointer>
#include <QTextEdit>

View File

@@ -4370,20 +4370,25 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateClass()
"template<class T>\n"
"class Foo\n"
"{\n"
" void fun@c();\n"
"};\n";
" void fun@c1();\n"
" void func2();\n"
"};\n\n"
"template<class T>\n"
"void Foo<T>::func2() {}\n";
QByteArray expected =
"template<class T>\n"
"class Foo\n"
"{\n"
" void fun@c();\n"
"};\n"
"\n"
" void func1();\n"
" void func2();\n"
"};\n\n"
"template<class T>\n"
"void Foo::func()\n" // Should really be Foo<T>::func()
"void Foo<T>::func1()\n"
"{\n"
"\n"
"}\n";
"}\n\n"
"template<class T>\n"
"void Foo<T>::func2() {}\n";
InsertDefFromDecl factory;
QuickFixOperationTest(singleDocument(original, expected), &factory);
@@ -4405,7 +4410,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_templateFunction()
"};\n"
"\n"
"template<class T>\n"
"void Foo::func()\n"
"void Foo::func<T>()\n"
"{\n"
"\n"
"}\n";

View File

@@ -3070,6 +3070,7 @@ public:
oo.showReturnTypes = true;
oo.showArgumentNames = true;
oo.showEnclosingTemplate = true;
oo.showTemplateParameters = true;
if (defPos == DefPosInsideClass) {
const int targetPos = targetFile->position(loc.line(), loc.column());

View File

@@ -135,7 +135,6 @@ void classifyFiles(const QSet<QString> &files, QStringList *headers, QStringList
}
void indexFindErrors(QFutureInterface<void> &indexingFuture,
const QFutureInterface<void> &superFuture,
const ParseParams params)
{
QStringList sources, headers;
@@ -149,7 +148,7 @@ void indexFindErrors(QFutureInterface<void> &indexingFuture,
timer.start();
for (int i = 0, end = files.size(); i < end ; ++i) {
if (indexingFuture.isCanceled() || superFuture.isCanceled())
if (indexingFuture.isCanceled())
break;
const QString file = files.at(i);
@@ -179,7 +178,6 @@ void indexFindErrors(QFutureInterface<void> &indexingFuture,
}
void index(QFutureInterface<void> &indexingFuture,
const QFutureInterface<void> &superFuture,
const ParseParams params)
{
QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor());
@@ -209,7 +207,7 @@ void index(QFutureInterface<void> &indexingFuture,
qCDebug(indexerLog) << "About to index" << files.size() << "files.";
for (int i = 0; i < files.size(); ++i) {
if (indexingFuture.isCanceled() || superFuture.isCanceled())
if (indexingFuture.isCanceled())
break;
const QString fileName = files.at(i);
@@ -243,9 +241,7 @@ void index(QFutureInterface<void> &indexingFuture,
qCDebug(indexerLog) << "Indexing finished.";
}
void parse(QFutureInterface<void> &indexingFuture,
const QFutureInterface<void> &superFuture,
const ParseParams params)
void parse(QFutureInterface<void> &indexingFuture, const ParseParams params)
{
const QSet<QString> &files = params.sourceFiles;
if (files.isEmpty())
@@ -254,9 +250,9 @@ void parse(QFutureInterface<void> &indexingFuture,
indexingFuture.setProgressRange(0, files.size());
if (FindErrorsIndexing)
indexFindErrors(indexingFuture, superFuture, params);
indexFindErrors(indexingFuture, params);
else
index(indexingFuture, superFuture, params);
index(indexingFuture, params);
indexingFuture.setProgressValue(files.size());
CppModelManager::instance()->finishedRefreshingSourceFiles(files);
@@ -349,9 +345,7 @@ BuiltinIndexingSupport::BuiltinIndexingSupport()
BuiltinIndexingSupport::~BuiltinIndexingSupport() = default;
QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(
const QFutureInterface<void> &superFuture,
const QSet<QString> &sourceFiles,
CppModelManager::ProgressNotificationMode mode)
const QSet<QString> &sourceFiles, CppModelManager::ProgressNotificationMode mode)
{
CppModelManager *mgr = CppModelManager::instance();
@@ -361,7 +355,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(
params.workingCopy = mgr->workingCopy();
params.sourceFiles = sourceFiles;
QFuture<void> result = Utils::runAsync(mgr->sharedThreadPool(), parse, superFuture, params);
QFuture<void> result = Utils::runAsync(mgr->sharedThreadPool(), parse, params);
if (m_synchronizer.futures().size() > 10) {
QList<QFuture<void> > futures = m_synchronizer.futures();

View File

@@ -38,8 +38,7 @@ public:
BuiltinIndexingSupport();
~BuiltinIndexingSupport() override;
QFuture<void> refreshSourceFiles(const QFutureInterface<void> &superFuture,
const QSet<QString> &sourceFiles,
QFuture<void> refreshSourceFiles(const QSet<QString> &sourceFiles,
CppModelManager::ProgressNotificationMode mode) override;
SymbolSearcher *createSymbolSearcher(const SymbolSearcher::Parameters &parameters,
const QSet<QString> &fileNames) override;

View File

@@ -48,6 +48,7 @@
#include <QtConcurrentMap>
#include <QCheckBox>
#include <QDir>
#include <QFutureWatcher>
#include <functional>

View File

@@ -31,7 +31,6 @@
#include <QObject>
#include <QPointer>
#include <QFuture>
#include <QFutureWatcher>
QT_FORWARD_DECLARE_CLASS(QTimer)

View File

@@ -78,9 +78,9 @@ class CPPTOOLS_EXPORT CppIndexingSupport
public:
virtual ~CppIndexingSupport() = 0;
virtual QFuture<void> refreshSourceFiles(const QFutureInterface<void> &superFuture,
const QSet<QString> &sourceFiles,
CppModelManager::ProgressNotificationMode mode) = 0;
virtual QFuture<void> refreshSourceFiles(const QSet<QString> &sourceFiles,
CppModelManager::ProgressNotificationMode mode)
= 0;
virtual SymbolSearcher *createSymbolSearcher(const SymbolSearcher::Parameters &parameters,
const QSet<QString> &fileNames) = 0;
};

View File

@@ -929,14 +929,6 @@ static QSet<QString> tooBigFilesRemoved(const QSet<QString> &files, int fileSize
QFuture<void> CppModelManager::updateSourceFiles(const QSet<QString> &sourceFiles,
ProgressNotificationMode mode)
{
const QFutureInterface<void> dummy;
return updateSourceFiles(dummy, sourceFiles, mode);
}
QFuture<void> CppModelManager::updateSourceFiles(const QFutureInterface<void> &superFuture,
const QSet<QString> &sourceFiles,
ProgressNotificationMode mode)
{
if (sourceFiles.isEmpty() || !d->m_indexerEnabled)
return QFuture<void>();
@@ -944,8 +936,8 @@ QFuture<void> CppModelManager::updateSourceFiles(const QFutureInterface<void> &s
const QSet<QString> filteredFiles = tooBigFilesRemoved(sourceFiles, indexerFileSizeLimitInMb());
if (d->m_indexingSupporter)
d->m_indexingSupporter->refreshSourceFiles(superFuture, filteredFiles, mode);
return d->m_internalIndexingSupport->refreshSourceFiles(superFuture, filteredFiles, mode);
d->m_indexingSupporter->refreshSourceFiles(filteredFiles, mode);
return d->m_internalIndexingSupport->refreshSourceFiles(filteredFiles, mode);
}
QList<ProjectInfo> CppModelManager::projectInfos() const
@@ -1078,25 +1070,23 @@ void CppModelManager::recalculateProjectPartMappings()
d->m_symbolFinder.clearCache();
}
void CppModelManager::watchForCanceledProjectIndexer(const QVector<QFuture<void>> &futures,
void CppModelManager::watchForCanceledProjectIndexer(const QFuture<void> &future,
ProjectExplorer::Project *project)
{
for (const QFuture<void> &future : futures) {
if (future.isCanceled() || future.isFinished())
continue;
if (future.isCanceled() || future.isFinished())
return;
auto watcher = new QFutureWatcher<void>(this);
connect(watcher, &QFutureWatcher<void>::canceled, this, [this, project, watcher]() {
if (d->m_projectToIndexerCanceled.contains(project)) // Project not yet removed
d->m_projectToIndexerCanceled.insert(project, true);
watcher->deleteLater();
});
connect(watcher, &QFutureWatcher<void>::finished, this, [this, project, watcher]() {
d->m_projectToIndexerCanceled.remove(project);
watcher->deleteLater();
});
watcher->setFuture(future);
}
auto watcher = new QFutureWatcher<void>(this);
connect(watcher, &QFutureWatcher<void>::canceled, this, [this, project, watcher]() {
if (d->m_projectToIndexerCanceled.contains(project)) // Project not yet removed
d->m_projectToIndexerCanceled.insert(project, true);
watcher->deleteLater();
});
connect(watcher, &QFutureWatcher<void>::finished, this, [this, project, watcher]() {
d->m_projectToIndexerCanceled.remove(project);
watcher->deleteLater();
});
watcher->setFuture(future);
}
void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const
@@ -1128,8 +1118,7 @@ void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const
}
}
QFuture<void> CppModelManager::updateProjectInfo(QFutureInterface<void> &futureInterface,
const ProjectInfo &newProjectInfo)
QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectInfo)
{
if (!newProjectInfo.isValid())
return QFuture<void>();
@@ -1221,12 +1210,12 @@ QFuture<void> CppModelManager::updateProjectInfo(QFutureInterface<void> &futureI
updateCppEditorDocuments(/*projectsUpdated = */ true);
// Trigger reindexing
const QFuture<void> indexingFuture = updateSourceFiles(futureInterface, filesToReindex,
const QFuture<void> indexingFuture = updateSourceFiles(filesToReindex,
ForcedProgressNotification);
if (!filesToReindex.isEmpty()) {
d->m_projectToIndexerCanceled.insert(project, false);
}
watchForCanceledProjectIndexer({futureInterface.future(), indexingFuture}, project);
watchForCanceledProjectIndexer(indexingFuture, project);
return indexingFuture;
}

View File

@@ -106,17 +106,13 @@ public:
QFuture<void> updateSourceFiles(const QSet<QString> &sourceFiles,
ProgressNotificationMode mode = ReservedProgressNotification);
QFuture<void> updateSourceFiles(const QFutureInterface<void> &superFuture,
const QSet<QString> &sourceFiles,
ProgressNotificationMode mode = ReservedProgressNotification);
void updateCppEditorDocuments(bool projectsUpdated = false) const;
WorkingCopy workingCopy() const;
QByteArray codeModelConfiguration() const;
QList<ProjectInfo> projectInfos() const;
ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
QFuture<void> updateProjectInfo(QFutureInterface<void> &futureInterface,
const ProjectInfo &newProjectInfo);
QFuture<void> updateProjectInfo(const ProjectInfo &newProjectInfo);
/// \return The project part with the given project file
ProjectPart::Ptr projectPartForId(const QString &projectPartId) const override;
@@ -274,7 +270,7 @@ private:
void initializeBuiltinModelManagerSupport();
void delayedGC();
void recalculateProjectPartMappings();
void watchForCanceledProjectIndexer(const QVector<QFuture<void> > &futures,
void watchForCanceledProjectIndexer(const QFuture<void> &future,
ProjectExplorer::Project *project);
void replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot);

View File

@@ -190,8 +190,7 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
{testDataDir.frameworksDir(false), HeaderPathType::Framework}};
pi.appendProjectPart(part);
QFutureInterface<void> dummy;
mm->updateProjectInfo(dummy, pi);
mm->updateProjectInfo(pi);
ProjectExplorer::HeaderPaths headerPaths = mm->headerPaths();
QCOMPARE(headerPaths.size(), 2);
@@ -223,8 +222,7 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
part->files << ProjectFile(source, ProjectFile::CXXSource);
pi.appendProjectPart(part);
QFutureInterface<void> dummy;
mm->updateProjectInfo(dummy, pi).waitForFinished();
mm->updateProjectInfo(pi).waitForFinished();
QCoreApplication::processEvents();
QVERIFY(mm->snapshot().contains(source));
@@ -323,8 +321,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
QFutureInterface<void> dummy;
mm->updateProjectInfo(dummy, pi);
mm->updateProjectInfo(pi);
CPlusPlus::Snapshot snapshot;
QSet<QString> refreshedFiles;
@@ -387,8 +384,7 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
// Reindexing triggers a reparsing thread
helper.resetRefreshedSourceFiles();
QFutureInterface<void> dummy;
QFuture<void> firstFuture = mm->updateProjectInfo(dummy, pi);
QFuture<void> firstFuture = mm->updateProjectInfo(pi);
QVERIFY(firstFuture.isStarted() || firstFuture.isRunning());
firstFuture.waitForFinished();
const QSet<QString> refreshedFiles = helper.waitForRefreshedSourceFiles();
@@ -396,7 +392,7 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
QVERIFY(refreshedFiles.contains(testCpp));
// No reindexing since nothing has changed
QFuture<void> subsequentFuture = mm->updateProjectInfo(dummy, pi);
QFuture<void> subsequentFuture = mm->updateProjectInfo(pi);
QVERIFY(subsequentFuture.isCanceled() && subsequentFuture.isFinished());
}

View File

@@ -42,9 +42,8 @@ using namespace ProjectExplorer;
namespace CppTools {
namespace Internal {
ProjectInfoGenerator::ProjectInfoGenerator(
const QFutureInterface<void> &futureInterface,
const ProjectUpdateInfo &projectUpdateInfo)
ProjectInfoGenerator::ProjectInfoGenerator(const QFutureInterface<ProjectInfo> &futureInterface,
const ProjectUpdateInfo &projectUpdateInfo)
: m_futureInterface(futureInterface)
, m_projectUpdateInfo(projectUpdateInfo)
{

View File

@@ -36,7 +36,7 @@ namespace Internal {
class ProjectInfoGenerator
{
public:
ProjectInfoGenerator(const QFutureInterface<void> &futureInterface,
ProjectInfoGenerator(const QFutureInterface<ProjectInfo> &futureInterface,
const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo);
ProjectInfo generate();
@@ -52,7 +52,7 @@ private:
Utils::LanguageExtensions languageExtensions);
private:
const QFutureInterface<void> m_futureInterface;
const QFutureInterface<ProjectInfo> m_futureInterface;
const ProjectExplorer::ProjectUpdateInfo &m_projectUpdateInfo;
bool m_cToolchainMissing = false;
bool m_cxxToolchainMissing = false;

View File

@@ -33,12 +33,16 @@
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
#include <QFutureInterface>
namespace CppTools {
CppProjectUpdater::CppProjectUpdater()
{
connect(&m_generateFutureWatcher, &QFutureWatcher<void>::finished,
this, &CppProjectUpdater::onProjectInfoGenerated);
connect(&m_generateFutureWatcher,
&QFutureWatcher<ProjectInfo>::finished,
this,
&CppProjectUpdater::onProjectInfoGenerated);
}
CppProjectUpdater::~CppProjectUpdater()
@@ -50,7 +54,6 @@ void CppProjectUpdater::update(const ProjectExplorer::ProjectUpdateInfo &project
{
// Stop previous update.
cancelAndWaitForFinished();
m_futureInterface = QFutureInterface<void>();
m_projectUpdateInfo = projectUpdateInfo;
@@ -60,26 +63,30 @@ void CppProjectUpdater::update(const ProjectExplorer::ProjectUpdateInfo &project
this, &CppProjectUpdater::onToolChainRemoved);
// Run the project info generator in a worker thread and continue if that one is finished.
const QFuture<ProjectInfo> future = Utils::runAsync([=]() {
m_generateFuture = Utils::runAsync([=](QFutureInterface<ProjectInfo> &futureInterface) {
ProjectUpdateInfo fullProjectUpdateInfo = projectUpdateInfo;
if (fullProjectUpdateInfo.rppGenerator)
fullProjectUpdateInfo.rawProjectParts = fullProjectUpdateInfo.rppGenerator();
Internal::ProjectInfoGenerator generator(m_futureInterface, fullProjectUpdateInfo);
return generator.generate();
Internal::ProjectInfoGenerator generator(futureInterface, fullProjectUpdateInfo);
futureInterface.reportResult(generator.generate());
});
m_generateFutureWatcher.setFuture(future);
m_generateFutureWatcher.setFuture(m_generateFuture);
}
void CppProjectUpdater::cancel()
{
disconnect(&m_generateFutureWatcher);
m_futureInterface.cancel();
m_generateFutureWatcher.setFuture({});
m_generateFuture.cancel();
m_updateFuture.cancel();
}
void CppProjectUpdater::cancelAndWaitForFinished()
{
cancel();
m_futureInterface.waitForFinished();
if (m_generateFuture.isRunning())
m_generateFuture.waitForFinished();
if (m_updateFuture.isRunning())
m_updateFuture.waitForFinished();
}
void CppProjectUpdater::onToolChainRemoved(ProjectExplorer::ToolChain *t)
@@ -96,11 +103,11 @@ void CppProjectUpdater::onProjectInfoGenerated()
disconnect(ToolChainManager::instance(), &ToolChainManager::toolChainRemoved,
this, &CppProjectUpdater::onToolChainRemoved);
if (m_futureInterface.isCanceled())
if (m_generateFutureWatcher.isCanceled() || m_generateFutureWatcher.future().resultCount() < 1)
return;
QFuture<void> future = CppModelManager::instance()
->updateProjectInfo(m_futureInterface, m_generateFutureWatcher.result());
m_updateFuture = CppModelManager::instance()->updateProjectInfo(
m_generateFutureWatcher.result());
}
CppProjectUpdaterFactory::CppProjectUpdaterFactory()

View File

@@ -29,7 +29,6 @@
#include "cpptools_global.h"
#include "projectinfo.h"
#include <QFutureInterface>
#include <QFutureWatcher>
namespace CppTools {
@@ -67,7 +66,8 @@ private:
private:
ProjectExplorer::ProjectUpdateInfo m_projectUpdateInfo;
QFutureInterface<void> m_futureInterface;
QFuture<ProjectInfo> m_generateFuture;
QFuture<void> m_updateFuture;
QFutureWatcher<ProjectInfo> m_generateFutureWatcher;
};

View File

@@ -32,6 +32,7 @@
#include <coreplugin/icore.h>
#include <cplusplus/ASTPath.h>
#include <cplusplus/LookupContext.h>
#include <utils/qtcassert.h>
@@ -545,6 +546,16 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
return noResult;
targetFile->cppDocument()->translationUnit()->getTokenStartPosition(functionDefinition->firstToken(), &line, &column);
const QList<AST *> path = ASTPath(targetFile->cppDocument())(line, column);
for (auto it = path.rbegin(); it != path.rend(); ++it) {
if (const auto templateDecl = (*it)->asTemplateDeclaration()) {
if (templateDecl->declaration == functionDefinition) {
targetFile->cppDocument()->translationUnit()->getTokenStartPosition(
templateDecl->firstToken(), &line, &column);
}
break;
}
}
}
return InsertionLocation(QString::fromUtf8(definitionFunction->fileName()), prefix, suffix, line, column);

View File

@@ -93,8 +93,7 @@ ModelManagerTestHelper::Project *ModelManagerTestHelper::createProject(const QSt
QSet<QString> ModelManagerTestHelper::updateProjectInfo(const CppTools::ProjectInfo &projectInfo)
{
resetRefreshedSourceFiles();
QFutureInterface<void> dummy;
CppModelManager::instance()->updateProjectInfo(dummy, projectInfo).waitForFinished();
CppModelManager::instance()->updateProjectInfo(projectInfo).waitForFinished();
QCoreApplication::processEvents();
return waitForRefreshedSourceFiles();
}

View File

@@ -145,7 +145,8 @@ bool SourcePathMappingModel::isNewPlaceHolder(const Mapping &m) const
// Return raw, unfixed mapping
Mapping SourcePathMappingModel::rawMappingAt(int row) const
{
return Mapping(item(row, SourceColumn)->text(), item(row, TargetColumn)->text());
return Mapping(QDir::fromNativeSeparators(item(row, SourceColumn)->text()),
QDir::fromNativeSeparators(item(row, TargetColumn)->text()));
}
// Return mapping, empty if it is the place holder.

View File

@@ -36,7 +36,6 @@
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QFutureWatcher>
#include <QStringList>
#include <QUrl>

View File

@@ -40,7 +40,6 @@
#include <utils/fileutils.h>
#include <QFuture>
#include <QFutureWatcher>
#include <QQueue>
namespace MesonProjectManager {

View File

@@ -29,7 +29,6 @@
#include <projectexplorer/projectnodes.h>
#include <QElapsedTimer>
#include <QFutureWatcher>
#include <QTimer>
namespace Nim {

View File

@@ -42,6 +42,7 @@
#include <utils/runextensions.h>
#include <QDateTime>
#include <QFutureInterface>
#include <QFutureWatcher>
#include <QProcess>
#include <QThreadPool>

View File

@@ -34,7 +34,6 @@
#include <utils/environment.h>
#include <QByteArray>
#include <QFuture>
#include <QHash>
#include <QList>
@@ -43,6 +42,13 @@
QT_FORWARD_DECLARE_CLASS(QProcess);
QT_FORWARD_DECLARE_CLASS(QThreadPool);
QT_BEGIN_NAMESPACE
template <typename T>
class QFutureInterface;
template <typename T>
class QFutureWatcher;
QT_END_NAMESPACE
namespace ProjectExplorer {

View File

@@ -382,10 +382,11 @@ FileType FileNode::fileType() const
return m_fileType;
}
static QList<FileNode *> scanForFilesRecursively(const Utils::FilePath &directory,
const std::function<FileNode *(const Utils::FilePath &)> factory,
QSet<QString> &visited, QFutureInterface<QList<FileNode*>> *future,
static QList<FileNode *> scanForFilesRecursively(QFutureInterface<QList<FileNode*>> &future,
double progressStart, double progressRange,
const Utils::FilePath &directory,
const std::function<FileNode *(const Utils::FilePath &)> factory,
QSet<QString> &visited,
const QList<Core::IVersionControl*> &versionControls)
{
QList<FileNode *> result;
@@ -403,7 +404,7 @@ static QList<FileNode *> scanForFilesRecursively(const Utils::FilePath &director
const double progressIncrement = progressRange / static_cast<double>(entries.count());
int lastIntProgress = 0;
for (const QFileInfo &entry : entries) {
if (future && future->isCanceled())
if (future.isCanceled())
return result;
const Utils::FilePath entryName = Utils::FilePath::fromString(entry.absoluteFilePath());
@@ -411,33 +412,29 @@ static QList<FileNode *> scanForFilesRecursively(const Utils::FilePath &director
return vc->isVcsFileOrDirectory(entryName);
})) {
if (entry.isDir())
result.append(scanForFilesRecursively(entryName, factory, visited, future, progress, progressIncrement, versionControls));
result.append(scanForFilesRecursively(future, progress, progressIncrement, entryName, factory, visited, versionControls));
else if (FileNode *node = factory(entryName))
result.append(node);
}
if (future) {
progress += progressIncrement;
const int intProgress = std::min(static_cast<int>(progressStart + progress), future->progressMaximum());
if (lastIntProgress < intProgress) {
future->setProgressValue(intProgress);
lastIntProgress = intProgress;
}
progress += progressIncrement;
const int intProgress = std::min(static_cast<int>(progressStart + progress), future.progressMaximum());
if (lastIntProgress < intProgress) {
future.setProgressValue(intProgress);
lastIntProgress = intProgress;
}
}
if (future)
future->setProgressValue(std::min(static_cast<int>(progressStart + progressRange), future->progressMaximum()));
future.setProgressValue(std::min(static_cast<int>(progressStart + progressRange), future.progressMaximum()));
return result;
}
QList<FileNode *>
FileNode::scanForFiles(const Utils::FilePath &directory,
const std::function<FileNode *(const Utils::FilePath &)> factory,
QFutureInterface<QList<FileNode *>> *future)
FileNode::scanForFiles(QFutureInterface<QList<FileNode *>> &future,
const Utils::FilePath &directory,
const std::function<FileNode *(const Utils::FilePath &)> factory)
{
QSet<QString> visited;
if (future)
future->setProgressRange(0, 1000000);
return scanForFilesRecursively(directory, factory, visited, future, 0.0, 1000000.0,
future.setProgressRange(0, 1000000);
return scanForFilesRecursively(future, 0.0, 1000000.0, directory, factory, visited,
Core::VcsManager::versionControls());
}

View File

@@ -201,9 +201,9 @@ public:
const FileNode *asFileNode() const final { return this; }
static QList<FileNode *>
scanForFiles(const Utils::FilePath &directory,
const std::function<FileNode *(const Utils::FilePath &fileName)> factory,
QFutureInterface<QList<FileNode *>> *future = nullptr);
scanForFiles(QFutureInterface<QList<FileNode *>> &future,
const Utils::FilePath &directory,
const std::function<FileNode *(const Utils::FilePath &fileName)> factory);
bool supportsAction(ProjectAction action, const Node *node) const override;
QString displayName() const override;

View File

@@ -64,12 +64,11 @@ bool TreeScanner::asyncScanForFiles(const Utils::FilePath &directory)
if (!m_futureWatcher.isFinished())
return false;
auto fi = new FutureInterface();
m_scanFuture = fi->future();
m_scanFuture = Utils::runAsync([this, directory](FutureInterface &fi) {
TreeScanner::scanForFiles(fi, directory, m_filter, m_factory);
});
m_futureWatcher.setFuture(m_scanFuture);
Utils::runAsync([this, fi, directory]() { TreeScanner::scanForFiles(fi, directory, m_filter, m_factory); });
return true;
}
@@ -145,14 +144,10 @@ FileType TreeScanner::genericFileType(const Utils::MimeType &mimeType, const Uti
return Node::fileTypeForMimeType(mimeType);
}
void TreeScanner::scanForFiles(FutureInterface *fi, const Utils::FilePath& directory,
void TreeScanner::scanForFiles(FutureInterface &fi, const Utils::FilePath& directory,
const FileFilter &filter, const FileTypeFactory &factory)
{
std::unique_ptr<FutureInterface> fip(fi);
fip->reportStarted();
Result nodes = FileNode::scanForFiles(
directory,
Result nodes = FileNode::scanForFiles(fi, directory,
[&filter, &factory](const Utils::FilePath &fn) -> FileNode * {
const Utils::MimeType mimeType = Utils::mimeTypeForFile(fn.toString());
@@ -166,13 +161,12 @@ void TreeScanner::scanForFiles(FutureInterface *fi, const Utils::FilePath& direc
type = factory(mimeType, fn);
return new FileNode(fn, type);
}, fip.get());
});
Utils::sort(nodes, ProjectExplorer::Node::sortByPath);
fip->setProgressValue(fip->progressMaximum());
fip->reportResult(nodes);
fip->reportFinished();
fi.setProgressValue(fi.progressMaximum());
fi.reportResult(nodes);
}
} // namespace ProjectExplorer

View File

@@ -87,7 +87,7 @@ signals:
void finished();
private:
static void scanForFiles(FutureInterface *fi, const Utils::FilePath &directory,
static void scanForFiles(FutureInterface &fi, const Utils::FilePath &directory,
const FileFilter &filter, const FileTypeFactory &factory);
private:

View File

@@ -72,6 +72,7 @@
#include <QDebug>
#include <QDir>
#include <QFileSystemWatcher>
#include <QFuture>
#include <QLoggingCategory>
#include <QTimer>

View File

@@ -36,7 +36,6 @@
#include <QStringList>
#include <QFutureInterface>
#include <QFuture>
QT_BEGIN_NAMESPACE
class QMakeGlobals;

View File

@@ -43,16 +43,16 @@ AnnotationCommentTab::AnnotationCommentTab(QWidget *parent)
ui->titleEdit->setModel(new QStringListModel{QStringList{"Description",
"Display Condition",
"helper_lines"
"highlight"
"helper lines",
"highlight",
"project author",
"project confirmed",
"project developer",
"project distributor",
"project modified",
"project type"
"project type",
"project version",
"Screen Description"
"Screen Description",
"Section"}});
connect(ui->titleEdit, &QComboBox::currentTextChanged,

View File

@@ -29,6 +29,10 @@
#include "annotation.h"
#include "qmlmodelnodeproxy.h"
#include <qmldesignerconstants.h>
#include <qmldesignerplugin.h>
#include <coreplugin/icore.h>
#include <QObject>
@@ -175,6 +179,7 @@ void AnnotationEditor::removeFullAnnotation()
void AnnotationEditor::acceptedClicked()
{
if (m_dialog) {
QmlDesignerPlugin::emitUsageStatistics(Constants::EVENT_ANNOTATION_ADDED);
QString customId = m_dialog->customId();
Annotation annotation = m_dialog->annotation();

View File

@@ -343,7 +343,7 @@ public:
parentNode = selectionContext().currentSingleSelectedNode().parentProperty().parentModelNode();
if (!ModelNode::isThisOrAncestorLocked(parentNode)) {
ActionTemplate *selectionAction = new ActionTemplate(QString(), &ModelNodeOperations::select);
ActionTemplate *selectionAction = new ActionTemplate("SELECTION", {}, &ModelNodeOperations::select);
selectionAction->setParent(menu());
selectionAction->setText(QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select parent: %1")).arg(
captionForModelNode(parentNode)));
@@ -363,7 +363,7 @@ public:
&& !ModelNode::isThisOrAncestorLocked(node)) {
selectionContext().setTargetNode(node);
QString what = QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select: %1")).arg(captionForModelNode(node));
ActionTemplate *selectionAction = new ActionTemplate(what, &ModelNodeOperations::select);
ActionTemplate *selectionAction = new ActionTemplate("SELECT", what, &ModelNodeOperations::select);
SelectionContext nodeSelectionContext = selectionContext();
nodeSelectionContext.setTargetNode(node);
@@ -546,7 +546,7 @@ public:
for (const QmlFlowItemNode &node : QmlFlowViewNode(selectionContext().rootNode()).flowItems()) {
if (node != selectionContext().currentSingleSelectedNode().parentProperty().parentModelNode()) {
QString what = QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Connect: %1")).arg(captionForModelNode(node));
ActionTemplate *connectionAction = new ActionTemplate(what, &ModelNodeOperations::addTransition);
ActionTemplate *connectionAction = new ActionTemplate("CONNECT", what, &ModelNodeOperations::addTransition);
SelectionContext nodeSelectionContext = selectionContext();
nodeSelectionContext.setTargetNode(node);

View File

@@ -29,6 +29,7 @@
#include "abstractaction.h"
#include "abstractactiongroup.h"
#include "qmlitemnode.h"
#include <qmldesignerplugin.h>
#include <coreplugin/actionmanager/command.h>
@@ -103,17 +104,19 @@ class ActionTemplate : public DefaultAction
{
public:
ActionTemplate(const QString &description, SelectionContextOperation action)
: DefaultAction(description), m_action(action)
ActionTemplate(const QByteArray &id, const QString &description, SelectionContextOperation action)
: DefaultAction(description), m_action(action), m_id(id)
{ }
void actionTriggered(bool b) override
{
QmlDesignerPlugin::emitUsageStatisticsContextAction(QString::fromUtf8(m_id));
m_selectionContext.setToggled(b);
m_action(m_selectionContext);
}
SelectionContextOperation m_action;
QByteArray m_id;
};
class ActionGroup : public AbstractActionGroup
@@ -202,7 +205,7 @@ public:
SelectionContextOperation selectionAction,
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
AbstractAction(new ActionTemplate(description, selectionAction)),
AbstractAction(new ActionTemplate(id, description, selectionAction)),
m_id(id),
m_category(category),
m_priority(priority),

View File

@@ -491,7 +491,7 @@ void DesignDocument::paste()
if (rootNode.type() == "empty")
return;
if (rootNode.id() == "designer__Selection") { // pasting multiple objects
if (rootNode.id() == "__multi__selection__") { // pasting multiple objects
currentModel()->attachView(&view);
ModelNode targetNode;
@@ -545,7 +545,7 @@ void DesignDocument::paste()
});
} else { // pasting single object
rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, rootNode]() {
rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, rootNode]() {
currentModel()->attachView(&view);
ModelNode pastedNode(view.insertModel(rootNode));
ModelNode targetNode;

View File

@@ -141,23 +141,23 @@ void DesignDocumentView::fromText(const QString &text)
inputModel->setFileUrl(model()->fileUrl());
QPlainTextEdit textEdit;
QString imports;
foreach (const Import &import, model()->imports())
imports += QStringLiteral("import ") + import.toString(true) + QLatin1Char(';') + QLatin1Char('\n');
const auto modelImports = model()->imports();
for (const Import &import : modelImports)
imports += "import " + import.toString(true) + QLatin1Char(';') + QLatin1Char('\n');
textEdit.setPlainText(imports + text);
NotIndentingTextEditModifier modifier(&textEdit);
QScopedPointer<RewriterView> rewriterView(new RewriterView(RewriterView::Amend, nullptr));
rewriterView->setCheckSemanticErrors(false);
rewriterView->setTextModifier(&modifier);
inputModel->setRewriterView(rewriterView.data());
RewriterView rewriterView;
rewriterView.setCheckSemanticErrors(false);
rewriterView.setTextModifier(&modifier);
inputModel->setRewriterView(&rewriterView);
rewriterView->restoreAuxiliaryData();
rewriterView.restoreAuxiliaryData();
if (rewriterView->errors().isEmpty() && rewriterView->rootModelNode().isValid()) {
ModelMerger merger(this);
if (rewriterView.errors().isEmpty() && rewriterView.rootModelNode().isValid()) {
try {
merger.replaceModel(rewriterView->rootModelNode());
replaceModel(rewriterView.rootModelNode());
} catch(Exception &/*e*/) {
/* e.showException(); Do not show any error if the clipboard contains invalid QML */
}
@@ -237,13 +237,13 @@ void DesignDocumentView::copyModelNodes(const QList<ModelNode> &nodesToCopy)
Q_ASSERT(view.rootModelNode().type() != "empty");
view.toClipboard();
} else { //multi items selected
} else { // multi items selected
foreach (ModelNode node, view.rootModelNode().directSubModelNodes()) {
node.destroy();
}
view.changeRootNodeType("QtQuick.Rectangle", 2, 0);
view.rootModelNode().setIdWithRefactoring("designer__Selection");
view.rootModelNode().setIdWithRefactoring("__multi__selection__");
foreach (const ModelNode &selectedNode, selectedNodes) {
ModelNode newNode(view.insertModel(selectedNode));

View File

@@ -572,6 +572,7 @@ void ItemLibraryWidget::addResources()
for (const AddResourceHandler &handler : handlers) {
QStringList fileNames = partitionedFileNames.values(category);
if (handler.category == category) {
QmlDesignerPlugin::emitUsageStatistics(Constants::EVENT_RESOURCE_IMPORTED + category);
if (!handler.operation(fileNames, document->fileName().parentDir().toString()))
Core::AsynchronousMessageBox::warning(tr("Failed to Add Files"), tr("Could not add %1 to project.").arg(fileNames.join(" ")));
break;

View File

@@ -793,6 +793,11 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i
}
}
TypeName propertyType(const NodeAbstractProperty &property)
{
return property.parentModelNode().metaInfo().propertyTypeName(property.name());
}
void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProperty,
const QList<ModelNode> &modelNodes,
int targetIndex,
@@ -801,7 +806,7 @@ void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty &parentProper
QTC_ASSERT(m_view, return);
auto doMoveNodesInteractive = [&parentProperty, modelNodes, targetIndex](){
const TypeName propertyQmlType = parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name());
const TypeName propertyQmlType = propertyType(parentProperty);
int idx = targetIndex;
for (const ModelNode &modelNode : modelNodes) {
if (modelNode.isValid()

View File

@@ -40,6 +40,8 @@
#include <variantproperty.h>
#include <nodelistproperty.h>
#include <qmldesignerconstants.h>
#include <qmldesignerplugin.h>
#include <qmlitemnode.h>
#include <qmlstate.h>
#include <annotationeditor/annotationeditor.h>
@@ -182,6 +184,8 @@ void StatesEditorView::addState()
if (!QmlVisualNode::isValidQmlVisualNode(rootModelNode()))
return;
QmlDesignerPlugin::emitUsageStatistics(Constants::EVENT_STATE_ADDED);
QStringList modelStateNames = rootStateGroup().names();
QString newStateName;
@@ -192,17 +196,12 @@ void StatesEditorView::addState()
break;
}
try {
executeInTransaction("addState", [this, newStateName]() {
rootModelNode().validId();
if ((rootStateGroup().allStates().count() < 1) && //QtQuick import might be missing
(!model()->hasImport(Import::createLibraryImport("QtQuick", "1.0"), true, true))) {
model()->changeImports({Import::createLibraryImport("QtQuick", "1.0")}, {});
}
ModelNode newState = rootStateGroup().addState(newStateName);
setCurrentState(newState);
} catch (const RewritingException &e) {
e.showException();
}
});
}
void StatesEditorView::resetModel()
@@ -236,9 +235,12 @@ void StatesEditorView::duplicateCurrentState()
QStringList stateNames = rootStateGroup().names();
while (stateNames.contains(newName + QString::number(i)))
i++;
const QString newStateName = newName + QString::number(i);
QmlModelState newState = state.duplicate(newName + QString::number(i));
setCurrentState(newState);
executeInTransaction("addState", [this, newStateName, state]() {
QmlModelState newState = state.duplicate(newStateName);
setCurrentState(newState);
});
}
void StatesEditorView::checkForStatesAvailability()
@@ -303,7 +305,7 @@ void StatesEditorView::renameState(int internalNodeId, const QString &newName)
setCurrentState(oldState);
}
} catch (const RewritingException &e) {
} catch (const RewritingException &e) {
e.showException();
}
}

View File

@@ -44,6 +44,7 @@
#include <rewritertransaction.h>
#include <variantproperty.h>
#include <viewmanager.h>
#include <qmldesignerconstants.h>
#include <qmldesignericons.h>
#include <qmldesignerplugin.h>
#include <qmlitemnode.h>
@@ -304,6 +305,8 @@ const QmlTimeline TimelineView::addNewTimeline()
QTC_ASSERT(isAttached(), return QmlTimeline());
QmlDesignerPlugin::emitUsageStatistics(Constants::EVENT_TIMELINE_ADDED);
try {
ensureQtQuickTimelineImport();
} catch (const Exception &e) {

View File

@@ -40,6 +40,7 @@
#include <rewritertransaction.h>
#include <variantproperty.h>
#include <viewmanager.h>
#include <qmldesignerconstants.h>
#include <qmldesignericons.h>
#include <qmldesignerplugin.h>
#include <qmlitemnode.h>
@@ -203,6 +204,8 @@ ModelNode TransitionEditorView::addNewTransition()
states = QmlVisualNode(root).states().allStates();
}
QmlDesignerPlugin::emitUsageStatistics(Constants::EVENT_TRANSITION_ADDED);
if (states.isEmpty()) {
Core::AsynchronousMessageBox::warning(tr("No States Defined"),
tr("There are no states defined in this component."));

View File

@@ -44,6 +44,7 @@ ImageCache::ImageCache(ImageCacheStorageInterface &storage,
while (isRunning()) {
if (auto [hasEntry, entry] = getEntry(); hasEntry) {
request(entry.name,
entry.state,
entry.requestType,
std::move(entry.captureCallback),
std::move(entry.abortCallback),
@@ -60,13 +61,11 @@ ImageCache::ImageCache(ImageCacheStorageInterface &storage,
ImageCache::~ImageCache()
{
clean();
stopThread();
m_condition.notify_all();
if (m_backgroundThread.joinable())
m_backgroundThread.join();
wait();
}
void ImageCache::request(Utils::SmallStringView name,
Utils::SmallStringView state,
ImageCache::RequestType requestType,
ImageCache::CaptureCallback captureCallback,
ImageCache::AbortCallback abortCallback,
@@ -74,9 +73,11 @@ void ImageCache::request(Utils::SmallStringView name,
ImageCacheGeneratorInterface &generator,
TimeStampProviderInterface &timeStampProvider)
{
const auto id = state.empty() ? Utils::PathString{name} : Utils::PathString{name, "+", state};
const auto timeStamp = timeStampProvider.timeStamp(name);
const auto entry = requestType == RequestType::Image ? storage.fetchImage(name, timeStamp)
: storage.fetchIcon(name, timeStamp);
const auto entry = requestType == RequestType::Image ? storage.fetchImage(id, timeStamp)
: storage.fetchIcon(id, timeStamp);
if (entry.hasEntry) {
if (entry.image.isNull())
@@ -84,23 +85,45 @@ void ImageCache::request(Utils::SmallStringView name,
else
captureCallback(entry.image);
} else {
generator.generateImage(name, timeStamp, std::move(captureCallback), std::move(abortCallback));
generator.generateImage(name,
state,
timeStamp,
std::move(captureCallback),
std::move(abortCallback));
}
}
void ImageCache::wait()
{
stopThread();
m_condition.notify_all();
if (m_backgroundThread.joinable())
m_backgroundThread.join();
}
void ImageCache::requestImage(Utils::PathString name,
ImageCache::CaptureCallback captureCallback,
AbortCallback abortCallback)
AbortCallback abortCallback,
Utils::SmallString state)
{
addEntry(std::move(name), std::move(captureCallback), std::move(abortCallback), RequestType::Image);
addEntry(std::move(name),
std::move(state),
std::move(captureCallback),
std::move(abortCallback),
RequestType::Image);
m_condition.notify_all();
}
void ImageCache::requestIcon(Utils::PathString name,
ImageCache::CaptureCallback captureCallback,
ImageCache::AbortCallback abortCallback)
ImageCache::AbortCallback abortCallback,
Utils::SmallString state)
{
addEntry(std::move(name), std::move(captureCallback), std::move(abortCallback), RequestType::Icon);
addEntry(std::move(name),
std::move(state),
std::move(captureCallback),
std::move(abortCallback),
RequestType::Icon);
m_condition.notify_all();
}
@@ -110,6 +133,13 @@ void ImageCache::clean()
m_generator.clean();
}
void ImageCache::waitForFinished()
{
wait();
m_generator.waitForFinished();
}
std::tuple<bool, ImageCache::Entry> ImageCache::getEntry()
{
std::unique_lock lock{m_mutex};
@@ -124,6 +154,7 @@ std::tuple<bool, ImageCache::Entry> ImageCache::getEntry()
}
void ImageCache::addEntry(Utils::PathString &&name,
Utils::SmallString &&state,
ImageCache::CaptureCallback &&captureCallback,
AbortCallback &&abortCallback,
RequestType requestType)
@@ -131,6 +162,7 @@ void ImageCache::addEntry(Utils::PathString &&name,
std::unique_lock lock{m_mutex};
m_entries.emplace_back(std::move(name),
std::move(state),
std::move(captureCallback),
std::move(abortCallback),
requestType);
@@ -160,7 +192,7 @@ void ImageCache::stopThread()
bool ImageCache::isRunning()
{
std::unique_lock lock{m_mutex};
return !m_finishing;
return !m_finishing || m_entries.size();
}
} // namespace QmlDesigner

View File

@@ -67,6 +67,7 @@ ImageCacheCollector::ImageCacheCollector(ImageCacheConnectionManager &connection
ImageCacheCollector::~ImageCacheCollector() = default;
void ImageCacheCollector::start(Utils::SmallStringView name,
Utils::SmallStringView state,
CaptureCallback captureCallback,
AbortCallback abortCallback)
{
@@ -91,6 +92,11 @@ void ImageCacheCollector::start(Utils::SmallStringView name,
return;
}
ModelNode stateNode = rewriterView.modelNodeForId(QString{state});
if (stateNode.isValid())
rewriterView.setCurrentStateNode(stateNode);
m_connectionManager.setCallback(std::move(captureCallback));
nodeInstanceView.setTarget(m_target.get());

View File

@@ -53,6 +53,7 @@ public:
~ImageCacheCollector();
void start(Utils::SmallStringView filePath,
Utils::SmallStringView state,
CaptureCallback captureCallback,
AbortCallback abortCallback) override;

View File

@@ -38,6 +38,7 @@ public:
using AbortCallback = std::function<void()>;
virtual void start(Utils::SmallStringView filePath,
Utils::SmallStringView state,
CaptureCallback captureCallback,
AbortCallback abortCallback)
= 0;

View File

@@ -44,21 +44,23 @@ ImageCacheGenerator::ImageCacheGenerator(ImageCacheCollectorInterface &collector
ImageCacheGenerator::~ImageCacheGenerator()
{
clean();
stopThread();
m_condition.notify_all();
if (m_backgroundThread)
m_backgroundThread->wait();
waitForFinished();
}
void ImageCacheGenerator::generateImage(Utils::SmallStringView name,
Sqlite::TimeStamp timeStamp,
ImageCacheGeneratorInterface::CaptureCallback &&captureCallback,
AbortCallback &&abortCallback)
void ImageCacheGenerator::generateImage(
Utils::SmallStringView name,
Utils::SmallStringView state,
Sqlite::TimeStamp timeStamp,
ImageCacheGeneratorInterface::CaptureCallback &&captureCallback,
AbortCallback &&abortCallback)
{
{
std::lock_guard lock{m_mutex};
m_tasks.emplace_back(name, timeStamp, std::move(captureCallback), std::move(abortCallback));
m_tasks.emplace_back(name,
state,
timeStamp,
std::move(captureCallback),
std::move(abortCallback));
}
m_condition.notify_all();
@@ -72,6 +74,15 @@ void ImageCacheGenerator::clean()
m_tasks.clear();
}
void ImageCacheGenerator::waitForFinished()
{
stopThread();
m_condition.notify_all();
if (m_backgroundThread)
m_backgroundThread->wait();
}
void ImageCacheGenerator::startGeneration()
{
while (isRunning()) {
@@ -82,7 +93,7 @@ void ImageCacheGenerator::startGeneration()
{
std::lock_guard lock{m_mutex};
if (m_finishing) {
if (m_finishing && m_tasks.empty()) {
m_storage.walCheckpointFull();
return;
}
@@ -94,6 +105,7 @@ void ImageCacheGenerator::startGeneration()
m_collector.start(
task.filePath,
task.state,
[this, task](QImage &&image) {
if (image.isNull())
task.abortCallback();
@@ -129,7 +141,7 @@ void ImageCacheGenerator::stopThread()
bool ImageCacheGenerator::isRunning()
{
std::unique_lock lock{m_mutex};
return !m_finishing;
return !m_finishing || m_tasks.size();
}
} // namespace QmlDesigner

View File

@@ -51,26 +51,32 @@ public:
~ImageCacheGenerator();
void generateImage(Utils::SmallStringView filePath,
Utils::SmallStringView state,
Sqlite::TimeStamp timeStamp,
CaptureCallback &&captureCallback,
AbortCallback &&abortCallback) override;
void clean() override;
void waitForFinished() override;
private:
struct Task
{
Task() = default;
Task(Utils::SmallStringView filePath,
Utils::SmallStringView state,
Sqlite::TimeStamp timeStamp,
CaptureCallback &&captureCallback,
AbortCallback &&abortCallback)
: filePath(filePath)
, state(std::move(state))
, captureCallback(std::move(captureCallback))
, abortCallback(std::move(abortCallback))
, timeStamp(timeStamp)
{}
Utils::PathString filePath;
Utils::SmallString state;
CaptureCallback captureCallback;
AbortCallback abortCallback;
Sqlite::TimeStamp timeStamp;

View File

@@ -39,12 +39,14 @@ public:
using AbortCallback = std::function<void()>;
virtual void generateImage(Utils::SmallStringView name,
Utils::SmallStringView state,
Sqlite::TimeStamp timeStamp,
CaptureCallback &&captureCallback,
AbortCallback &&abortCallback)
= 0;
virtual void clean() = 0;
virtual void waitForFinished() = 0;
protected:
~ImageCacheGeneratorInterface() = default;

View File

@@ -54,12 +54,15 @@ public:
void requestImage(Utils::PathString name,
CaptureCallback captureCallback,
AbortCallback abortCallback);
AbortCallback abortCallback,
Utils::SmallString state = {});
void requestIcon(Utils::PathString name,
CaptureCallback captureCallback,
AbortCallback abortCallback);
AbortCallback abortCallback,
Utils::SmallString state = {});
void clean();
void waitForFinished();
private:
enum class RequestType { Image, Icon };
@@ -67,16 +70,19 @@ private:
{
Entry() = default;
Entry(Utils::PathString name,
Utils::SmallString state,
CaptureCallback &&captureCallback,
AbortCallback &&abortCallback,
RequestType requestType)
: name{std::move(name)}
, state{std::move(state)}
, captureCallback{std::move(captureCallback)}
, abortCallback{std::move(abortCallback)}
, requestType{requestType}
{}
Utils::PathString name;
Utils::SmallString state;
CaptureCallback captureCallback;
AbortCallback abortCallback;
RequestType requestType = RequestType::Image;
@@ -84,6 +90,7 @@ private:
std::tuple<bool, Entry> getEntry();
void addEntry(Utils::PathString &&name,
Utils::SmallString &&state,
CaptureCallback &&captureCallback,
AbortCallback &&abortCallback,
RequestType requestType);
@@ -92,6 +99,7 @@ private:
void stopThread();
bool isRunning();
static void request(Utils::SmallStringView name,
Utils::SmallStringView state,
ImageCache::RequestType requestType,
ImageCache::CaptureCallback captureCallback,
ImageCache::AbortCallback abortCallback,
@@ -99,6 +107,9 @@ private:
ImageCacheGeneratorInterface &generator,
TimeStampProviderInterface &timeStampProvider);
private:
void wait();
private:
std::vector<Entry> m_entries;
mutable std::mutex m_mutex;

View File

@@ -75,7 +75,7 @@ public:
};
public:
RewriterView(DifferenceHandling differenceHandling, QObject *parent);
RewriterView(DifferenceHandling differenceHandling = RewriterView::Amend, QObject *parent = nullptr);
~RewriterView() override;
void modelAttached(Model *model) override;

View File

@@ -473,9 +473,7 @@ QPixmap NodeInstance::blurredRenderPixmap() const
void NodeInstance::setRenderPixmap(const QImage &image)
{
d->renderPixmap = QPixmap::fromImage(image);
#ifndef QMLDESIGNER_TEST
d->renderPixmap.setDevicePixelRatio(QmlDesignerPlugin::formEditorDevicePixelRatio());
#endif
d->blurredRenderPixmap = QPixmap();
}

View File

@@ -856,7 +856,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
QList<ModelNode> nodeList = allModelNodes();
QList<NodeInstance> instanceList;
foreach (const ModelNode &node, nodeList) {
for (const ModelNode &node : std::as_const(nodeList)) {
NodeInstance instance = loadNode(node);
if (!isSkippedNode(node))
instanceList.append(instance);
@@ -868,7 +868,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
QList<BindingProperty> bindingPropertyList;
QVector<PropertyValueContainer> auxiliaryContainerVector;
foreach (const ModelNode &node, nodeList) {
for (const ModelNode &node : std::as_const(nodeList)) {
variantPropertyList.append(node.variantProperties());
bindingPropertyList.append(node.bindingProperties());
if (node.isValid() && hasInstanceForModelNode(node)) {
@@ -883,9 +883,8 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
}
}
QVector<InstanceContainer> instanceContainerList;
foreach (const NodeInstance &instance, instanceList) {
for (const NodeInstance &instance : std::as_const(instanceList)) {
InstanceContainer::NodeSourceType nodeSourceType = static_cast<InstanceContainer::NodeSourceType>(instance.modelNode().nodeSourceType());
InstanceContainer::NodeMetaType nodeMetaType = InstanceContainer::ObjectMetaType;
@@ -911,7 +910,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
}
QVector<ReparentContainer> reparentContainerList;
foreach (const NodeInstance &instance, instanceList) {
for (const NodeInstance &instance : std::as_const(instanceList)) {
if (instance.modelNode().hasParentProperty()) {
NodeAbstractProperty parentProperty = instance.modelNode().parentProperty();
ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForModelNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name());
@@ -920,7 +919,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
}
QVector<IdContainer> idContainerList;
foreach (const NodeInstance &instance, instanceList) {
for (const NodeInstance &instance : std::as_const(instanceList)) {
QString id = instance.modelNode().id();
if (!id.isEmpty()) {
IdContainer container(instance.instanceId(), id);
@@ -929,7 +928,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
}
QVector<PropertyValueContainer> valueContainerList;
foreach (const VariantProperty &property, variantPropertyList) {
for (const VariantProperty &property : std::as_const(variantPropertyList)) {
ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node);
@@ -939,7 +938,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
}
QVector<PropertyBindingContainer> bindingContainerList;
foreach (const BindingProperty &property, bindingPropertyList) {
for (const BindingProperty &property : std::as_const(bindingPropertyList)) {
ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node);
@@ -949,7 +948,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
}
QVector<AddImportContainer> importVector;
foreach (const Import &import, model()->imports())
for (const Import &import : model()->imports())
importVector.append(AddImportContainer(import.url(), import.file(), import.version(), import.alias(), import.importPaths()));
QVector<MockupTypeContainer> mockupTypesVector;
@@ -993,19 +992,23 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
if (auto multiLanguageAspect = QmlProjectManager::QmlMultiLanguageAspect::current(m_currentTarget))
lastUsedLanguage = multiLanguageAspect->currentLocale();
return CreateSceneCommand(
instanceContainerList,
reparentContainerList,
idContainerList,
valueContainerList,
bindingContainerList,
auxiliaryContainerVector,
importVector,
mockupTypesVector,
model()->fileUrl(),
m_edit3DToolStates[model()->fileUrl()],
lastUsedLanguage
);
ModelNode stateNode = currentStateNode();
qint32 stateInstanceId = 0;
if (stateNode.isValid() && stateNode.metaInfo().isSubclassOf("QtQuick.State", 1, 0))
stateInstanceId = stateNode.internalId();
return CreateSceneCommand(instanceContainerList,
reparentContainerList,
idContainerList,
valueContainerList,
bindingContainerList,
auxiliaryContainerVector,
importVector,
mockupTypesVector,
model()->fileUrl(),
m_edit3DToolStates[model()->fileUrl()],
lastUsedLanguage,
stateInstanceId);
}
ClearSceneCommand NodeInstanceView::createClearSceneCommand() const

View File

@@ -1062,6 +1062,14 @@ static QByteArray getPackage(const QByteArray &name)
return nameComponents.join('.');
}
QList<TypeName> qtObjectTypes()
{
static QList<TypeName> typeNames = {"QML.QtObject", "QtQml.QtObject", "<cpp>.QObject"};
return typeNames;
}
bool NodeMetaInfoPrivate::cleverCheckType(const TypeName &otherType) const
{
if (otherType == qualfiedTypeName())
@@ -1070,6 +1078,9 @@ bool NodeMetaInfoPrivate::cleverCheckType(const TypeName &otherType) const
if (isFileComponent())
return false;
if (qtObjectTypes().contains(qualfiedTypeName()) && qtObjectTypes().contains(otherType))
return true;
const QByteArray typeName = getUnqualifiedName(otherType);
const QByteArray package = getPackage(otherType);

View File

@@ -1025,7 +1025,11 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
collectLinkErrors(&errors, ctxt);
setupImports(m_document, differenceHandler);
setupPossibleImports(snapshot, m_vContext);
if (!justSanityCheck)
setupPossibleImports(snapshot, m_vContext);
qCInfo(rewriterBenchmark) << "imports setup:" << time.elapsed();
collectImportErrors(&errors);

View File

@@ -77,6 +77,13 @@ const char M_VIEW_WORKSPACES[] = "QmlDesigner.Menu.View.Workspaces";
const int MODELNODE_PREVIEW_IMAGE_DIMENSIONS = 150;
const char EVENT_TIMELINE_ADDED[] = "Timeline Added";
const char EVENT_TRANSITION_ADDED[] = "Transition Added";
const char EVENT_STATE_ADDED[] = "State Added";
const char EVENT_ANNOTATION_ADDED[] = "Annotation Added";
const char EVENT_RESOURCE_IMPORTED[] = "Resource Imported ";
const char EVENT_ACTION_EXECUTED[] = "Action Executed ";
namespace Internal {
enum { debug = 0 };
}

View File

@@ -547,6 +547,17 @@ double QmlDesignerPlugin::formEditorDevicePixelRatio()
return topLevelWindows.constFirst()->screen()->devicePixelRatio();
}
void QmlDesignerPlugin::emitUsageStatistics(const QString &identifier)
{
QTC_ASSERT(instance(), return);
emit instance()->usageStatisticsNotifier(identifier);
}
void QmlDesignerPlugin::emitUsageStatisticsContextAction(const QString &identifier)
{
emitUsageStatistics(Constants::EVENT_ACTION_EXECUTED + identifier);
}
QmlDesignerPlugin *QmlDesignerPlugin::instance()
{
return m_instance;

View File

@@ -82,6 +82,13 @@ public:
static double formEditorDevicePixelRatio();
static void emitUsageStatistics(const QString &identifier);
static void emitUsageStatisticsContextAction(const QString &identifier);
signals:
void usageStatisticsNotifier(const QString &identifier);
private: // functions
void integrateIntoQtCreator(QWidget *modeWidget);
void showDesigner();

View File

@@ -25,14 +25,15 @@
#include "qmljsfindreferences.h"
#include <texteditor/basefilefind.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/searchresultwindow.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/filesearch.h>
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/progressmanager/futureprogress.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/basefilefind.h>
#include <utils/filesearch.h>
#include <utils/runextensions.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsbind.h>
@@ -47,15 +48,14 @@
#include "qmljseditorconstants.h"
#include <QTime>
#include <QTimer>
#include <QtConcurrentRun>
#include <QtConcurrentMap>
#include <QApplication>
#include <QDebug>
#include <QDir>
#include <QApplication>
#include <QFuture>
#include <QLabel>
#include <utils/runextensions.h>
#include <QTime>
#include <QTimer>
#include <QtConcurrentMap>
#include <functional>

View File

@@ -29,7 +29,6 @@
#include <QMutex>
#include <QObject>
#include <QFuture>
#include <QFutureWatcher>
#include <QPointer>

View File

@@ -34,7 +34,6 @@
#include <tracing/timelinetracefile.h>
#include <QFutureInterface>
#include <QObject>
#include <QVector>
#include <QString>

View File

@@ -60,13 +60,12 @@
#include <resourceeditor/resourcenode.h>
#include <QDir>
#include <QUrl>
#include <QFileInfo>
#include <QFuture>
#include <QCoreApplication>
#include <QDir>
#include <QFileInfo>
#include <QProcess>
#include <QRegularExpression>
#include <QUrl>
#include <algorithm>
@@ -1054,7 +1053,8 @@ QString BaseQtVersionPrivate::findHostBinary(HostBinaries binary) const
if (HostOsInfo::isWindowsHost()) {
possibleCommands << "uic.exe";
} else {
possibleCommands << "uic-qt4" << "uic4" << "uic";
const QString majorString = QString::number(q->qtVersion().majorVersion);
possibleCommands << ("uic-qt" + majorString) << ("uic" + majorString) << "uic";
}
break;
case QScxmlc:

View File

@@ -464,7 +464,7 @@ void Parser::Private::parseCostItem(const char *begin, const char *end)
if (currentCallData.calledFile == -1) {
currentCallData.calledFile = currentDifferingFile != -1 ? currentDifferingFile : lastFile;
//HACK: workaround issue where sometimes fi=??? lines are prepended to function calls
if (unknownFiles.contains(currentCallData.calledFile))
if (unknownFiles.contains(quint64(currentCallData.calledFile)))
currentCallData.calledFile = lastFile;
}
if (currentCallData.calledObject == -1)

View File

@@ -33,7 +33,6 @@
#include <valgrind/valgrindrunner.h>
#include <QFutureInterface>
#include <QFutureWatcher>
namespace Valgrind {
namespace Internal {