From e974f0733e5d42ede7e30e1d98d3fe3d0500e8a1 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 26 Jun 2017 12:57:33 +0200 Subject: [PATCH 1/3] ProjectExplorer: Introduce priorities for RunControlFactories This can be used by downstream plugins to overrule existing RunControlFactories. Change-Id: I23c8e3983827dfa1b5f780664d2e539e908944aa Reviewed-by: Eike Ziller Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/projectexplorer.cpp | 10 +++++++++- src/plugins/projectexplorer/runconfiguration.cpp | 13 +++++++++++++ src/plugins/projectexplorer/runconfiguration.h | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 61c3bf50a70..e6c25c84b61 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1980,10 +1980,18 @@ void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro) // NBS TODO implement more than one runner static IRunControlFactory *findRunControlFactory(RunConfiguration *config, Core::Id mode) { - return ExtensionSystem::PluginManager::getObject( + auto factories = ExtensionSystem::PluginManager::getObjects( [&config, &mode](IRunControlFactory *factory) { return factory->canRun(config, mode); }); + + if (factories.isEmpty()) + return nullptr; + auto it = std::max_element(factories.begin(), factories.end(), + [](IRunControlFactory *a, IRunControlFactory *b) { + return a->priority() < b->priority(); + }); + return *it; } void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *runConfiguration, Core::Id runMode) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index da5c7b398b9..e06bbda79d6 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -501,6 +501,19 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunCon than it needs to be. */ + +const char PRIORITY_KEY[] = "RunControlFactoryPriority"; + +int ProjectExplorer::IRunControlFactory::priority() const +{ + return property(PRIORITY_KEY).toInt(); // 0 by default. +} + +void IRunControlFactory::setPriority(int priority) +{ + setProperty(PRIORITY_KEY, priority); +} + namespace Internal { class RunControlPrivate diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 3efb2dae5b2..9a330afb9f2 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -335,6 +335,10 @@ public: virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) = 0; virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc); + + int priority() const; +protected: + void setPriority(int priority); // Higher values will be preferred. }; class PROJECTEXPLORER_EXPORT RunConfigWidget : public QWidget From bde0f1b0ff7ff8779f19a42f28508fcfb314f5b2 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 29 Jun 2017 12:03:10 +0200 Subject: [PATCH 2/3] DiffEditor: disable saveAs action during reload Change-Id: I6786139c1cd9c9e3c0786b14da058cb260fba3ed Reviewed-by: Eike Ziller --- src/plugins/diffeditor/diffeditordocument.cpp | 10 ++++++++++ src/plugins/diffeditor/diffeditordocument.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/diffeditor/diffeditordocument.cpp b/src/plugins/diffeditor/diffeditordocument.cpp index 9928ef61972..aac0ba2f063 100644 --- a/src/plugins/diffeditor/diffeditordocument.cpp +++ b/src/plugins/diffeditor/diffeditordocument.cpp @@ -203,11 +203,19 @@ QString DiffEditorDocument::fallbackSaveAsPath() const return QDir::homePath(); } +bool DiffEditorDocument::isSaveAsAllowed() const +{ + return !isReloading(); +} + bool DiffEditorDocument::save(QString *errorString, const QString &fileName, bool autoSave) { Q_UNUSED(errorString) Q_UNUSED(autoSave) + if (isReloading()) + return false; + const bool ok = write(fileName, format(), plainText(), errorString); if (!ok) @@ -330,6 +338,7 @@ void DiffEditorDocument::beginReload() { emit aboutToReload(); m_isReloading = true; + emit changed(); const bool blocked = blockSignals(true); setDiffFiles(QList(), QString()); setDescription(QString()); @@ -339,6 +348,7 @@ void DiffEditorDocument::beginReload() void DiffEditorDocument::endReload(bool success) { m_isReloading = false; + emit changed(); emit reloadFinished(success); } diff --git a/src/plugins/diffeditor/diffeditordocument.h b/src/plugins/diffeditor/diffeditordocument.h index c61d17ad909..18c73b61cee 100644 --- a/src/plugins/diffeditor/diffeditordocument.h +++ b/src/plugins/diffeditor/diffeditordocument.h @@ -70,7 +70,7 @@ public: QString fallbackSaveAsPath() const override; QString fallbackSaveAsFileName() const override; - bool isSaveAsAllowed() const override { return true; } + bool isSaveAsAllowed() const override; bool save(QString *errorString, const QString &fileName, bool autoSave) override; void reload(); bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; From c9345084c76cb8e6546da20e177090c612dc275a Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 29 Jun 2017 23:27:10 +0300 Subject: [PATCH 3/3] C++: Use #pragma once in cplusplus-update-frontend Change-Id: Ie4821a04706ee55b4ec17cf73356c15c333b3324 Reviewed-by: Nikolai Kosjar --- .../3rdparty/cplusplus/ASTPatternBuilder.h | 5 +---- .../cplusplus-update-frontend.cpp | 21 ++++++------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/libs/3rdparty/cplusplus/ASTPatternBuilder.h b/src/libs/3rdparty/cplusplus/ASTPatternBuilder.h index f3934b7ba1c..9270a3429ca 100644 --- a/src/libs/3rdparty/cplusplus/ASTPatternBuilder.h +++ b/src/libs/3rdparty/cplusplus/ASTPatternBuilder.h @@ -26,8 +26,7 @@ // Changes will be lost. // -#ifndef CPLUSPLUS_AST_PATTERN_BUILDER_H -#define CPLUSPLUS_AST_PATTERN_BUILDER_H +#pragma once #include "CPlusPlusForwardDeclarations.h" #include "AST.h" @@ -1385,5 +1384,3 @@ public: }; } // end of namespace CPlusPlus - -#endif // CPLUSPLUS_AST_PATTERN_BUILDER_H diff --git a/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp index 9a5b7c67007..2b83d7fa4ea 100644 --- a/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp +++ b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp @@ -1246,8 +1246,7 @@ void generateASTVisitor_H(const Snapshot &, const QDir &cplusplusDir, QTextStream out(&file); out << copyrightHeader << "\n" -"#ifndef CPLUSPLUS_ASTVISITOR_H\n" -"#define CPLUSPLUS_ASTVISITOR_H\n" +"#pragma once\n" "\n" "#include \"CPlusPlusForwardDeclarations.h\"\n" "#include \"ASTfwd.h\"\n" @@ -1317,9 +1316,7 @@ void generateASTVisitor_H(const Snapshot &, const QDir &cplusplusDir, " TranslationUnit *_translationUnit;\n" "};\n" "\n" -"} // namespace CPlusPlus\n" -"\n" -"#endif // CPLUSPLUS_ASTVISITOR_H\n"; +"} // namespace CPlusPlus\n"; closeAndPrintFilePath(file); } @@ -1339,8 +1336,7 @@ void generateASTMatcher_H(const Snapshot &, const QDir &cplusplusDir, QTextStream out(&file); out << copyrightHeader << "\n" -"#ifndef ASTMATCHER_H\n" -"#define ASTMATCHER_H\n" +"#pragma once\n" "\n" "#include \"ASTfwd.h\"\n" "\n" @@ -1360,9 +1356,7 @@ void generateASTMatcher_H(const Snapshot &, const QDir &cplusplusDir, out << "};\n" "\n" -"} // namespace CPlusPlus\n" -"\n" -"#endif // CPLUSPLUS_ASTMATCHER_H\n"; +"} // namespace CPlusPlus\n"; closeAndPrintFilePath(file); } @@ -1574,8 +1568,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir) out << copyrightHeader << generatedHeader - << "#ifndef CPLUSPLUS_AST_PATTERN_BUILDER_H" << endl - << "#define CPLUSPLUS_AST_PATTERN_BUILDER_H" << endl + << "#pragma once" << endl << endl << "#include \"CPlusPlusForwardDeclarations.h\"" << endl << "#include \"AST.h\"" << endl @@ -1683,9 +1676,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir) out << "};" << endl << endl - << "} // end of namespace CPlusPlus" << endl - << endl - << "#endif // CPLUSPLUS_AST_PATTERN_BUILDER_H" << endl; + << "} // end of namespace CPlusPlus" << endl; closeAndPrintFilePath(file); }