chiark / gitweb /
doxygen: fix crash with class inheritance outside of a namespace.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 7 May 2018 20:53:05 +0000 (22:53 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 7 May 2018 20:56:07 +0000 (22:56 +0200)
Amazing that I didn't come across this until now.

doxygen/dox2html5.py
doxygen/test/cpp_derived/classBaseOutsideANamespace.html [new file with mode: 0644]
doxygen/test/cpp_derived/classDerivedOutsideANamespace.html [new file with mode: 0644]
doxygen/test/cpp_derived/input.h
doxygen/test/test_cpp.py

index 54c9def5f554a2c3efdee7aaac70e2d49ffef4e8..c70df8c7c38ee0658d54904c184e194b0e79c583 100755 (executable)
@@ -2139,7 +2139,7 @@ def parse_xml(state: State, xml: str):
                     class_ = Empty()
                     class_.kind = symbol.kind
                     class_.url = symbol.url
-                    class_.name = symbol.leaf_name if symbol.parent.startswith(state.compounds[compound.id].parent) else symbol.name
+                    class_.name = symbol.leaf_name if state.compounds[compound.id].parent and symbol.parent.startswith(state.compounds[compound.id].parent) else symbol.name
                     class_.brief = symbol.brief
                     class_.templates = symbol.templates
                     class_.is_deprecated = symbol.is_deprecated
@@ -2162,7 +2162,7 @@ def parse_xml(state: State, xml: str):
                     class_ = Empty()
                     class_.kind = symbol.kind
                     class_.url = symbol.url
-                    class_.name = symbol.leaf_name if symbol.parent.startswith(state.compounds[compound.id].parent) else symbol.name
+                    class_.name = symbol.leaf_name if state.compounds[compound.id].parent and symbol.parent.startswith(state.compounds[compound.id].parent) else symbol.name
                     class_.brief = symbol.brief
                     class_.templates = symbol.templates
                     class_.is_deprecated = symbol.is_deprecated
diff --git a/doxygen/test/cpp_derived/classBaseOutsideANamespace.html b/doxygen/test/cpp_derived/classBaseOutsideANamespace.html
new file mode 100644 (file)
index 0000000..58fc4d9
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>BaseOutsideANamespace class | My Project</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+  <link rel="stylesheet" href="m-dark+doxygen.compiled.css" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Project</a>
+    </div>
+  </div>
+</nav></header>
+<main><article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>
+          BaseOutsideANamespace <span class="m-thin">class</span>
+        </h1>
+        <p>A base class outside of a namespace.</p>
+        <section id="derived-classes">
+          <h2><a href="#derived-classes">Derived classes</a></h2>
+          <dl class="m-dox">
+            <dt>
+              class <a href="classDerivedOutsideANamespace.html" class="m-dox">DerivedOutsideANamespace</a>
+            </dt>
+            <dd>A derived class outside of a namespace.</dd>
+          </dl>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
diff --git a/doxygen/test/cpp_derived/classDerivedOutsideANamespace.html b/doxygen/test/cpp_derived/classDerivedOutsideANamespace.html
new file mode 100644 (file)
index 0000000..fc670e8
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>DerivedOutsideANamespace class | My Project</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+  <link rel="stylesheet" href="m-dark+doxygen.compiled.css" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Project</a>
+    </div>
+  </div>
+</nav></header>
+<main><article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>
+          DerivedOutsideANamespace <span class="m-thin">class</span>
+        </h1>
+        <p>A derived class outside of a namespace.</p>
+        <section id="base-classes">
+          <h2><a href="#base-classes">Base classes</a></h2>
+          <dl class="m-dox">
+            <dt>
+              class <a href="classBaseOutsideANamespace.html" class="m-dox">BaseOutsideANamespace</a>
+            </dt>
+            <dd>A base class outside of a namespace.</dd>
+          </dl>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index 5554104d461973f881622414bab4880340533d91..2800095bb5e3d4ef39cb77b6b705f9b3a1dcb09b 100644 (file)
@@ -41,3 +41,9 @@ namespace Namespace {
 struct UndocumentedDerived: A {};
 
 }
+
+/** @brief A base class outside of a namespace */
+class BaseOutsideANamespace {};
+
+/** @brief A derived class outside of a namespace */
+class DerivedOutsideANamespace: public BaseOutsideANamespace {};
index 1b3d6e71e602888259b1bef182ee99529431dada..d88db18ff1d82a6cc5d988c3b65b6ae02c6f02df 100644 (file)
@@ -59,3 +59,5 @@ class Derived(IntegrationTestCase):
         self.assertEqual(*self.actual_expected_contents('classNamespace_1_1PrivateBase.html'))
         self.assertEqual(*self.actual_expected_contents('classAnother_1_1ProtectedBase.html'))
         self.assertEqual(*self.actual_expected_contents('classNamespace_1_1VirtualBase.html'))
+        self.assertEqual(*self.actual_expected_contents('classBaseOutsideANamespace.html'))
+        self.assertEqual(*self.actual_expected_contents('classDerivedOutsideANamespace.html'))