From: Rico Tzschichholz Date: Sun, 25 Oct 2020 16:50:26 +0000 (+0100) Subject: valadoc: Don't call CodeContext.pop() on empty stack X-Git-Tag: 0.51.1~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eebf2ad8ae3c3773739437acabac4966ed7effbf;p=thirdparty%2Fvala.git valadoc: Don't call CodeContext.pop() on empty stack Otherwise this results in an expected assertion. Fixes https://gitlab.gnome.org/GNOME/vala/issues/1064 --- diff --git a/valadoc/valadoc.vala b/valadoc/valadoc.vala index b9ae48c50..6ed4a6792 100644 --- a/valadoc/valadoc.vala +++ b/valadoc/valadoc.vala @@ -139,14 +139,18 @@ public class ValaDoc : Object { return true; } - private static int quit (ErrorReporter reporter) { + private static int quit (ErrorReporter reporter, bool pop_context = false) { if (reporter.errors == 0 && (!fatal_warnings || reporter.warnings == 0)) { stdout.printf ("Succeeded - %d warning(s)\n", reporter.warnings); - Vala.CodeContext.pop (); + if (pop_context) { + Vala.CodeContext.pop (); + } return 0; } else { stdout.printf ("Failed: %d error(s), %d warning(s)\n", reporter.errors, reporter.warnings); - Vala.CodeContext.pop (); + if (pop_context) { + Vala.CodeContext.pop (); + } return 1; } } @@ -251,7 +255,7 @@ public class ValaDoc : Object { Doclet? doclet = null; ModuleLoader? modules = create_module_loader (reporter, out doclet); if (reporter.errors > 0 || modules == null) { - return quit (reporter); + return quit (reporter, true); } // Create tree: @@ -259,7 +263,7 @@ public class ValaDoc : Object { Valadoc.Api.Tree doctree = builder.build (settings, reporter); if (reporter.errors > 0) { doclet = null; - return quit (reporter); + return quit (reporter, true); } SymbolResolver resolver = new SymbolResolver (builder); doctree.accept (resolver); @@ -271,7 +275,7 @@ public class ValaDoc : Object { // process documentation Valadoc.DocumentationParser docparser = new Valadoc.DocumentationParser (settings, reporter, doctree, modules); if (!doctree.create_tree()) { - return quit (reporter); + return quit (reporter, true); } DocumentationImporter[] importers = { @@ -281,17 +285,17 @@ public class ValaDoc : Object { doctree.parse_comments (docparser); if (reporter.errors > 0) { - return quit (reporter); + return quit (reporter, true); } doctree.import_comments (importers, import_packages, import_directories); if (reporter.errors > 0) { - return quit (reporter); + return quit (reporter, true); } doctree.check_comments (docparser); if (reporter.errors > 0) { - return quit (reporter); + return quit (reporter, true); } if (ValaDoc.gir_name != null) { @@ -303,12 +307,12 @@ public class ValaDoc : Object { settings.gir_version, settings.pkg_name); if (reporter.errors > 0) { - return quit (reporter); + return quit (reporter, true); } } doclet.process (settings, doctree, reporter); - return quit (reporter); + return quit (reporter, true); } static int main (string[] args) {