Commit 9724cf68 authored by Eike Ziller's avatar Eike Ziller

Help: Work around issue with Visual Studio < 2013

Visual Studio before 2013 had bugs in bool conversion of std::function,
leading to "true" in some cases where it shouldn't.

Task-number: QTCREATORBUG-14399
Change-Id: I8a1ad2f952247049355e11337ddf99f380ebde98
Reviewed-by: default avatarOliver Wolff <oliver.wolff@theqtcompany.com>
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent 19200258
......@@ -369,24 +369,37 @@ HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });
ViewerFactory factory;
// TODO: Visual Studio < 2013 has a bug in std::function's operator bool, which in this case
// leads to succeeding boolean checks on factory which should not succeed.
// So we may not check against "if (!factory)"
bool factoryFound = false;
// check requested backend
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
if (!backend.isEmpty()) {
factory = factories.value(backend);
if (!factory)
if (!factories.contains(backend)) {
qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
} else {
factory = factories.value(backend);
factoryFound = true;
}
}
// default setting
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
if (!factory)
if (!factoryFound && factories.contains(QLatin1String("native"))) {
factory = factories.value(QLatin1String("native"));
factoryFound = true;
}
#endif
if (!factory)
if (!factoryFound && factories.contains(QLatin1String("qtwebkit"))) {
factory = factories.value(QLatin1String("qtwebkit"));
if (!factory)
factoryFound = true;
}
if (!factoryFound && factories.contains(QLatin1String("textbrowser"))) {
factory = factories.value(QLatin1String("textbrowser"));
QTC_ASSERT(factory, return 0);
factoryFound = true;
}
QTC_ASSERT(factoryFound, return 0);
HelpViewer *viewer = factory();
// initialize font
......
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