Commit 3c2f4089 authored by Eike Ziller's avatar Eike Ziller
Browse files

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: default avatarMaurice Kalinowski <maurice.kalinowski@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent f7a1c1ca
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment