]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
valadoc: Don't call CodeContext.pop() on empty stack
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 25 Oct 2020 16:50:26 +0000 (17:50 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 25 Oct 2020 16:50:26 +0000 (17:50 +0100)
Otherwise this results in an expected assertion.

Fixes https://gitlab.gnome.org/GNOME/vala/issues/1064

valadoc/valadoc.vala

index b9ae48c504419f0295cc9e908e21bda305476178..6ed4a6792d485ea7f41a54183c8aa9bb790311a1 100644 (file)
@@ -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) {