forked from qt-creator/qt-creator
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: Oliver Wolff <oliver.wolff@theqtcompany.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -369,24 +369,37 @@ HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
|
|||||||
factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });
|
factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });
|
||||||
|
|
||||||
ViewerFactory factory;
|
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
|
// check requested backend
|
||||||
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
|
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
|
||||||
if (!backend.isEmpty()) {
|
if (!backend.isEmpty()) {
|
||||||
factory = factories.value(backend);
|
if (!factories.contains(backend)) {
|
||||||
if (!factory)
|
|
||||||
qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
|
qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
|
||||||
|
} else {
|
||||||
|
factory = factories.value(backend);
|
||||||
|
factoryFound = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// default setting
|
// default setting
|
||||||
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
|
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
|
||||||
if (!factory)
|
if (!factoryFound && factories.contains(QLatin1String("native"))) {
|
||||||
factory = factories.value(QLatin1String("native"));
|
factory = factories.value(QLatin1String("native"));
|
||||||
|
factoryFound = true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!factory)
|
if (!factoryFound && factories.contains(QLatin1String("qtwebkit"))) {
|
||||||
factory = factories.value(QLatin1String("qtwebkit"));
|
factory = factories.value(QLatin1String("qtwebkit"));
|
||||||
if (!factory)
|
factoryFound = true;
|
||||||
|
}
|
||||||
|
if (!factoryFound && factories.contains(QLatin1String("textbrowser"))) {
|
||||||
factory = factories.value(QLatin1String("textbrowser"));
|
factory = factories.value(QLatin1String("textbrowser"));
|
||||||
|
factoryFound = true;
|
||||||
QTC_ASSERT(factory, return 0);
|
}
|
||||||
|
QTC_ASSERT(factoryFound, return 0);
|
||||||
HelpViewer *viewer = factory();
|
HelpViewer *viewer = factory();
|
||||||
|
|
||||||
// initialize font
|
// initialize font
|
||||||
|
Reference in New Issue
Block a user