From 3c2f408963c286cf21a7c43993c793e38e503370 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 5 Apr 2016 10:11:48 +0200 Subject: [PATCH] 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 Reviewed-by: Eike Ziller --- src/libs/utils/runextensions.h | 33 +++++++++-------- .../texteditor/generichighlighter/manager.cpp | 35 ++++++------------- .../texteditor/generichighlighter/manager.h | 12 +++---- 3 files changed, 35 insertions(+), 45 deletions(-) diff --git a/src/libs/utils/runextensions.h b/src/libs/utils/runextensions.h index bd20b862c47..c40899eb907 100644 --- a/src/libs/utils/runextensions.h +++ b/src/libs/utils/runextensions.h @@ -38,6 +38,24 @@ #include +// 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 +static testCallOperatorYes testCallOperator(decltype(&C::operator())); + +template +static testCallOperatorNo testCallOperator(...); + +template +struct hasCallOperator +{ + static const bool value = (sizeof(testCallOperator(0)) == sizeof(testCallOperatorYes)); +}; + namespace Utils { namespace Internal { @@ -54,21 +72,6 @@ namespace Internal { a QFutureInterface& as its first parameter and returns void. */ -template -struct hasCallOperator -{ - using yes = char; - using no = struct { char foo[2]; }; - - template - static yes test(decltype(&C::operator())); - - template - static no test(...); - - static const bool value = (sizeof(test(0)) == sizeof(yes)); -}; - template struct resultType; diff --git a/src/plugins/texteditor/generichighlighter/manager.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp index 33cb5b88a36..6f32e833b9d 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 +static const int kMaxProgress = 200; - void operator()(QFutureInterface &future); - - QStringList m_definitionsPaths; - static const int kMaxProgress; -}; - -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 &future) +static void processHighlightingFiles(QFutureInterface &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 future = Utils::runAsync(ManagerProcessor()); + QStringList definitionsPaths; + const HighlighterSettings &settings = TextEditorSettings::highlighterSettings(); + definitionsPaths.append(settings.definitionFilesPath()); + if (settings.useFallbackLocation()) + definitionsPaths.append(settings.fallbackDefinitionFilesPath()); + + QFuture 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 41fa1d79f54..0a6dfeb70a2 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 m_idByName; + QHash m_idByMimeType; + QHash m_definitionsMetaData; + }; private: void registerHighlightingFilesFinished(); void downloadAvailableDefinitionsListFinished(); @@ -100,12 +106,6 @@ private: QHash > m_definitions; QHash m_availableDefinitions; - struct RegisterData - { - QHash m_idByName; - QHash m_idByMimeType; - QHash m_definitionsMetaData; - }; RegisterData m_register; bool m_hasQueuedRegistration; QFutureWatcher m_registeringWatcher;