From 4629958928d5bcf3b6f4e8854ed342c8b8bd39f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 7 May 2018 22:53:05 +0200 Subject: [PATCH] doxygen: fix crash with class inheritance outside of a namespace. Amazing that I didn't come across this until now. --- doxygen/dox2html5.py | 4 +- .../classBaseOutsideANamespace.html | 40 +++++++++++++++++++ .../classDerivedOutsideANamespace.html | 40 +++++++++++++++++++ doxygen/test/cpp_derived/input.h | 6 +++ doxygen/test/test_cpp.py | 2 + 5 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 doxygen/test/cpp_derived/classBaseOutsideANamespace.html create mode 100644 doxygen/test/cpp_derived/classDerivedOutsideANamespace.html diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 54c9def5..c70df8c7 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -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 index 00000000..58fc4d92 --- /dev/null +++ b/doxygen/test/cpp_derived/classBaseOutsideANamespace.html @@ -0,0 +1,40 @@ + + + + + BaseOutsideANamespace class | My Project + + + + + +
+
+ + diff --git a/doxygen/test/cpp_derived/classDerivedOutsideANamespace.html b/doxygen/test/cpp_derived/classDerivedOutsideANamespace.html new file mode 100644 index 00000000..fc670e89 --- /dev/null +++ b/doxygen/test/cpp_derived/classDerivedOutsideANamespace.html @@ -0,0 +1,40 @@ + + + + + DerivedOutsideANamespace class | My Project + + + + + +
+
+
+
+
+

+ DerivedOutsideANamespace class +

+

A derived class outside of a namespace.

+
+

Base classes

+
+
+ class BaseOutsideANamespace +
+
A base class outside of a namespace.
+
+
+
+
+
+
+ + diff --git a/doxygen/test/cpp_derived/input.h b/doxygen/test/cpp_derived/input.h index 5554104d..2800095b 100644 --- a/doxygen/test/cpp_derived/input.h +++ b/doxygen/test/cpp_derived/input.h @@ -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 {}; diff --git a/doxygen/test/test_cpp.py b/doxygen/test/test_cpp.py index 1b3d6e71..d88db18f 100644 --- a/doxygen/test/test_cpp.py +++ b/doxygen/test/test_cpp.py @@ -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')) -- 2.30.2