Help: Avoid looking up invalid help ID over and over again

Make the help link cache remember that it tried before.

Change-Id: Id9d07a7b86c4fa856b7fa3a5e17cd5d4115861ff
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2019-01-25 15:48:24 +01:00
parent 282805b66d
commit 121e721067
2 changed files with 5 additions and 3 deletions

View File

@@ -144,7 +144,7 @@ QString HelpItem::extractContent(bool extended) const
QMap<QString, QUrl> HelpItem::links() const
{
if (m_helpLinks.isEmpty())
if (!m_helpLinks)
m_helpLinks = Core::HelpManager::linksForIdentifier(m_helpId);
return m_helpLinks;
return *m_helpLinks;
}

View File

@@ -27,6 +27,8 @@
#include "core_global.h"
#include <utils/optional.h>
#include <QMap>
#include <QString>
#include <QUrl>
@@ -77,7 +79,7 @@ private:
QString m_helpId;
QString m_docMark;
Category m_category = Unknown;
mutable QMap<QString, QUrl> m_helpLinks; // cached help links
mutable Utils::optional<QMap<QString, QUrl>> m_helpLinks; // cached help links
};
} // namespace Core