diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp
index 2c91f5cba4b4de5e271aefd262de2977d5af8d5e..dabf25c79179192cdf4646fed04bd85486ef2995 100644
--- a/src/plugins/cppeditor/cpphoverhandler.cpp
+++ b/src/plugins/cppeditor/cpphoverhandler.cpp
@@ -297,23 +297,24 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
         }
     }
 
+    if (m_helpEngineNeedsSetup
+        && m_helpEngine->registeredDocumentations().count() > 0) {
+        m_helpEngine->setupData();
+        m_helpEngineNeedsSetup = false;
+    }
+    QMap<QString, QUrl> helpLinks;
+
     if (m_toolTip.isEmpty()) {
         foreach (const Document::Include &incl, doc->includes()) {
             if (incl.line() == lineNumber) {
                 m_toolTip = QDir::toNativeSeparators(incl.fileName());
                 m_helpId = QFileInfo(incl.fileName()).fileName();
+                helpLinks = m_helpEngine->linksForIdentifier(m_helpId);
                 break;
             }
         }
     }
 
-    if (m_helpEngineNeedsSetup
-        && m_helpEngine->registeredDocumentations().count() > 0) {
-        m_helpEngine->setupData();
-        m_helpEngineNeedsSetup = false;
-    }
-
-    QMap<QString, QUrl> helpLinks;
     if (m_helpId.isEmpty()) {
         // Move to the end of a qualified name
         bool stop = false;