diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp
index 137da05ffb75df400647d72a0f67b3529aee74b5..60ed949819ad001de884ab842ded34d5701dddba 100644
--- a/src/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/htmlgenerator.cpp
@@ -3943,8 +3943,15 @@ QString HtmlGenerator::linkForNode(const Node *node, const Node *relative)
     if (node && node->parent() &&
         (node->parent()->isQmlType() || node->parent()->isJsType())
         && node->parent()->isAbstract()) {
-        if (Generator::qmlTypeContext())
-            fn = fileName(Generator::qmlTypeContext());
+        if (Generator::qmlTypeContext()) {
+            if (Generator::qmlTypeContext()->inherits(node->parent())) {
+                fn = fileName(Generator::qmlTypeContext());
+            }
+            else if (node->parent()->isInternal()) {
+                node->doc().location().warning(tr("Cannot link to property in internal type '%1'").arg(node->parent()->name()));
+                return QString();
+            }
+        }
     }
     QString link = fn;
 
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index e2ed08032ee5981b8593f5ccc5b3a1b75d9d1505..7e3b2d96a936ad03331e46b7811315dec96ddbeb 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -2668,6 +2668,20 @@ QString QmlTypeNode::logicalModuleIdentifier() const
     return (logicalModule_ ? logicalModule_->logicalModuleIdentifier() : QString());
 }
 
+/*!
+  Returns true if this QML type inherits \a type.
+ */
+bool QmlTypeNode::inherits(Aggregate* type)
+{
+    QmlTypeNode* qtn = qmlBaseNode();
+    while (qtn != 0) {
+        if (qtn == type)
+            return true;
+        qtn = qtn->qmlBaseNode();
+    }
+    return false;
+}
+
 /*!
   Constructs a Qml basic type node. The new node has the given
   \a parent and \a name.
diff --git a/src/qdoc/node.h b/src/qdoc/node.h
index faea2dcb16cfc5bb0224d8e777ad1c65afcc4a3f..38fc99f03fe3c98fedcf27720ca578b2a0d2694d 100644
--- a/src/qdoc/node.h
+++ b/src/qdoc/node.h
@@ -677,6 +677,7 @@ public:
     static void addInheritedBy(const Node *base, Node* sub);
     static void subclasses(const Node *base, NodeList& subs);
     static void terminate();
+    bool inherits(Aggregate* type);
 
 public:
     static bool qmlOnly;