aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2016-04-05 10:11:48 +0200
committerEike Ziller <eike.ziller@theqtcompany.com>2016-04-05 10:46:17 +0000
commit3c2f408963c286cf21a7c43993c793e38e503370 (patch)
tree97c50acfc6a954460919712fc9ef4f5c043ecd59
parentf7a1c1caa015ae0674791bcaba9ee2d03e7b5272 (diff)
Runextensions/hasCallOperator: Fix build with MSVC2015 Update 2
Looks like MSVC has issues (internal compiler error) with the "templates in templates" when used from within a namespace, as well as a few other problems... Simplify the code paths for hasCallOperator. Change-Id: I934401a884398967ac95d7e218525cc316d9000a Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
-rw-r--r--src/libs/utils/runextensions.h33
-rw-r--r--src/plugins/texteditor/generichighlighter/manager.cpp35
-rw-r--r--src/plugins/texteditor/generichighlighter/manager.h12
3 files changed, 35 insertions, 45 deletions
diff --git a/src/libs/utils/runextensions.h b/src/libs/utils/runextensions.h
index bd20b862c4..c40899eb90 100644
--- a/src/libs/utils/runextensions.h
+++ b/src/libs/utils/runextensions.h
@@ -38,6 +38,24 @@
#include <functional>
+// hasCallOperator & Co must be outside of any namespace
+// because of internal compiler error with MSVC2015 Update 2
+
+using testCallOperatorYes = char;
+using testCallOperatorNo = struct { char foo[2]; };
+
+template<typename C>
+static testCallOperatorYes testCallOperator(decltype(&C::operator()));
+
+template<typename>
+static testCallOperatorNo testCallOperator(...);
+
+template<typename T>
+struct hasCallOperator
+{
+ static const bool value = (sizeof(testCallOperator<T>(0)) == sizeof(testCallOperatorYes));
+};
+
namespace Utils {
namespace Internal {
@@ -54,21 +72,6 @@ namespace Internal {
a QFutureInterface& as its first parameter and returns void.
*/
-template<typename T>
-struct hasCallOperator
-{
- using yes = char;
- using no = struct { char foo[2]; };
-
- template<typename C>
- static yes test(decltype(&C::operator()));
-
- template<typename C>
- static no test(...);
-
- static const bool value = (sizeof(test<T>(0)) == sizeof(yes));
-};
-
template <typename Function>
struct resultType;
diff --git a/src/plugins/texteditor/generichighlighter/manager.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp
index 33cb5b88a3..6f32e833b9 100644
--- a/src/plugins/texteditor/generichighlighter/manager.cpp
+++ b/src/plugins/texteditor/generichighlighter/manager.cpp
@@ -248,35 +248,16 @@ bool Manager::isBuildingDefinition(const QString &id) const
return m_isBuildingDefinition.contains(id);
}
-class ManagerProcessor
-{
-public:
- ManagerProcessor();
- // TODO: make move-only when we can require MSVC2015
-
- void operator()(QFutureInterface<Manager::RegisterData> &future);
-
- QStringList m_definitionsPaths;
- static const int kMaxProgress;
-};
+static const int kMaxProgress = 200;
-const int ManagerProcessor::kMaxProgress = 200;
-
-ManagerProcessor::ManagerProcessor()
-{
- const HighlighterSettings &settings = TextEditorSettings::highlighterSettings();
- m_definitionsPaths.append(settings.definitionFilesPath());
- if (settings.useFallbackLocation())
- m_definitionsPaths.append(settings.fallbackDefinitionFilesPath());
-}
-
-void ManagerProcessor::operator()(QFutureInterface<Manager::RegisterData> &future)
+static void processHighlightingFiles(QFutureInterface<Manager::RegisterData> &future,
+ QStringList definitionPaths)
{
future.setProgressRange(0, kMaxProgress);
Manager::RegisterData data;
// iterate through paths in order, high priority > low priority
- foreach (const QString &path, m_definitionsPaths) {
+ foreach (const QString &path, definitionPaths) {
if (path.isEmpty())
continue;
@@ -322,7 +303,13 @@ void Manager::registerHighlightingFiles()
if (!m_registeringWatcher.isRunning()) {
clear();
- QFuture<RegisterData> future = Utils::runAsync(ManagerProcessor());
+ QStringList definitionsPaths;
+ const HighlighterSettings &settings = TextEditorSettings::highlighterSettings();
+ definitionsPaths.append(settings.definitionFilesPath());
+ if (settings.useFallbackLocation())
+ definitionsPaths.append(settings.fallbackDefinitionFilesPath());
+
+ QFuture<RegisterData> future = Utils::runAsync(processHighlightingFiles, definitionsPaths);
m_registeringWatcher.setFuture(future);
} else {
m_hasQueuedRegistration = true;
diff --git a/src/plugins/texteditor/generichighlighter/manager.h b/src/plugins/texteditor/generichighlighter/manager.h
index 41fa1d79f5..0a6dfeb70a 100644
--- a/src/plugins/texteditor/generichighlighter/manager.h
+++ b/src/plugins/texteditor/generichighlighter/manager.h
@@ -80,6 +80,12 @@ public:
static DefinitionMetaDataPtr parseMetadata(const QFileInfo &fileInfo);
+ struct RegisterData
+ {
+ QHash<QString, QString> m_idByName;
+ QHash<QString, QString> m_idByMimeType;
+ QHash<QString, DefinitionMetaDataPtr> m_definitionsMetaData;
+ };
private:
void registerHighlightingFilesFinished();
void downloadAvailableDefinitionsListFinished();
@@ -100,12 +106,6 @@ private:
QHash<QString, QSharedPointer<HighlightDefinition> > m_definitions;
QHash<QString, DefinitionMetaDataPtr> m_availableDefinitions;
- struct RegisterData
- {
- QHash<QString, QString> m_idByName;
- QHash<QString, QString> m_idByMimeType;
- QHash<QString, DefinitionMetaDataPtr> m_definitionsMetaData;
- };
RegisterData m_register;
bool m_hasQueuedRegistration;
QFutureWatcher<RegisterData> m_registeringWatcher;