]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Release taken references to CodeContext after using it
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Dec 2017 09:23:14 +0000 (10:23 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Dec 2017 09:26:31 +0000 (10:26 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=712694

codegen/valaccodebasemodule.vala
codegen/valagirwriter.vala
vala/valaflowanalyzer.vala
vala/valagenieparser.vala
vala/valagirparser.vala
vala/valaparser.vala
vala/valasemanticanalyzer.vala
vala/valasymbolresolver.vala

index f99acce089ffb918adbce628074579b1d3567320..56ff942919df76eff52932a4a25531d2bad09bfa 100644 (file)
@@ -526,6 +526,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        var stream = FileStream.open (context.symbols_filename, "w");
                        if (stream == null) {
                                Report.error (null, "unable to open `%s' for writing".printf (context.symbols_filename));
+                               this.context = null;
                                return;
                        }
 
@@ -552,6 +553,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                Report.error (null, "unable to open `%s' for writing".printf (context.internal_header_filename));
                        }
                }
+
+               this.context = null;
        }
 
        public void push_context (EmitContext emit_context) {
index 47e1d2a9d78c039d2ff8d2ea78e1f80edb8c1bd8..bd814f08e40b794d6e080c08416b976fe49915fb 100644 (file)
@@ -165,6 +165,7 @@ public class Vala.GIRWriter : CodeVisitor {
                stream = FileStream.open (filename, "w");
                if (stream == null) {
                        Report.error (null, "unable to open `%s' for writing".printf (filename));
+                       this.context = null;
                        return;
                }
 
@@ -196,6 +197,8 @@ public class Vala.GIRWriter : CodeVisitor {
                if (our_namespaces.size == 0) {
                        Report.error (null, "No suitable namespace found to export for GIR");
                }
+
+               this.context = null;
        }
 
        private void write_doc (string? comment) {
index 3683b817f29c607960d8d8f27774678d6eb625e9..122e58d7f0bb45aa9630f6d1ff3d53bb7e17fadb 100644 (file)
@@ -112,6 +112,8 @@ public class Vala.FlowAnalyzer : CodeVisitor {
                                file.accept (this);
                        }
                }
+
+               this.context = null;
        }
 
        public override void visit_source_file (SourceFile source_file) {
index df4f66e9b608462c2847a619c46989ea22cb9998..f9aba46ffc056d8d5cec1b43828286ee4126f448 100644 (file)
@@ -86,6 +86,7 @@ public class Vala.Genie.Parser : CodeVisitor {
        public void parse (CodeContext context) {
                this.context = context;
                context.accept (this);
+               this.context = null;
        }
 
        public override void visit_source_file (SourceFile source_file) {
index 0754e8d34a353bae6a0bfa765fb70cec7f3981d3..edc580c6804045f76180c33f82566942405f8287 100644 (file)
@@ -1327,6 +1327,8 @@ public class Vala.GirParser : CodeVisitor {
                foreach (var metadata in metadata_roots) {
                        report_unused_metadata (metadata);
                }
+
+               this.context = null;
        }
 
        void map_vala_to_gir () {
index ec5e34e82034460d67ff1265ec014f534d2bec9c..6228ba98ede7b39ae364ced65b4205d85e773ba5 100644 (file)
@@ -76,6 +76,7 @@ public class Vala.Parser : CodeVisitor {
        public void parse (CodeContext context) {
                this.context = context;
                context.accept (this);
+               this.context = null;
        }
 
        public override void visit_source_file (SourceFile source_file) {
index a7bbb18e6bf97aa0d2641b03bcda2ec13f2064ad..fce226b1f2352e83c153a60bd02509dd2f9e00c4 100644 (file)
@@ -28,9 +28,8 @@ using GLib;
  * Code visitor analyzing and checking code.
  */
 public class Vala.SemanticAnalyzer : CodeVisitor {
-       public CodeContext context { get; set; }
+       CodeContext context;
 
-       public Symbol root_symbol;
        public Symbol current_symbol { get; set; }
        public SourceFile current_source_file { get; set; }
 
@@ -181,7 +180,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
        public void analyze (CodeContext context) {
                this.context = context;
 
-               root_symbol = context.root;
+               var root_symbol = context.root;
 
                bool_type = new BooleanType ((Struct) root_symbol.scope.lookup ("bool"));
                string_type = new ObjectType ((Class) root_symbol.scope.lookup ("string"));
@@ -224,6 +223,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                current_symbol = root_symbol;
                context.root.check (context);
                context.accept (this);
+
+               this.context = null;
        }
 
        public override void visit_source_file (SourceFile file) {
index 32c84e4c3b8a65e6714fe4236e9e17646d6873f5..53ad7282150b1b888e6ac92f2ee024f0a4e4b78d 100644 (file)
@@ -42,6 +42,9 @@ public class Vala.SymbolResolver : CodeVisitor {
                root_symbol = context.root;
 
                context.root.accept (this);
+
+               root_symbol = null;
+               this.context = null;
        }
        
        public override void visit_namespace (Namespace ns) {