Clone in a terminal:
Commit b0d888a
Johan Mattsson - 2014-04-05T10:59:36+00:00
b0d888a353f40ccaaf7fbc0129f64d4c849b19adjohan.mattsson.m@gmail.com

Fix memory leak

Changed files (9)

Diff

diff --git a/libbirdfont/Argument.vala b/libbirdfont/Argument.valaindex 6194e7d..8cc03e0 100644--- a/libbirdfont/Argument.vala+++ b/libbirdfont/Argument.vala@@ -71,7 +71,7 @@ public class Argument : GLib.Object { 				a == "--mac" || 				a == "--android" || 				a == "--log" ||-				a == "--donated") {+				a == "--no-ucd") { 				prev = a; 				i++; 				continue;diff --git a/libbirdfont/CharDatabaseParser.vala b/libbirdfont/CharDatabaseParser.valaindex 594f9a0..263fe39 100644--- a/libbirdfont/CharDatabaseParser.vala+++ b/libbirdfont/CharDatabaseParser.vala@@ -91,6 +91,11 @@ public class CharDatabaseParser : GLib.Object { 		string description = ""; 		File file; +		if (BirdFont.has_argument ("--no-ucd")) {+			warning ("Not loading UCD.");+			return;+		}+ 		file = get_unicode_database (); 		 		try {diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex e0c3c35..61ade84 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -354,12 +354,17 @@ public class Glyph : FontDisplay { 	} 	 	private void remove_lines () {+		unowned List<Line> li; 		while (vertical_help_lines.length () != 0) {-			vertical_help_lines.remove_link (vertical_help_lines.first ());+			li = vertical_help_lines.first ();+			li.data.unref ();+			vertical_help_lines.delete_link (li); 		}  		while (horizontal_help_lines.length () != 0) {-			horizontal_help_lines.remove_link (horizontal_help_lines.first ());+			li = horizontal_help_lines.first ();+			li.data.unref ();+			horizontal_help_lines.delete_link (li); 		}		 	} 	@@ -422,8 +427,8 @@ public class Glyph : FontDisplay { 				right_limit = pos; 			}); 		-		// lists of help lines are sorted and lines are added only if -		// they are important for a particular glyph.+		// lists of lines are sorted and lines are added only if +		// they are relevant for a particular glyph. 		 		// left to right 		add_line (left_line);@@ -544,10 +549,8 @@ public class Glyph : FontDisplay { 	private void add_line (Line line) { 		if (line.is_vertical ()) { 			vertical_help_lines.append (line);-			line.list_item = vertical_help_lines.last (); 		} else { 			horizontal_help_lines.append (line);-			line.list_item = horizontal_help_lines.last (); 		}  		sort_help_lines ();@@ -1219,14 +1222,21 @@ public class Glyph : FontDisplay { 	}  	public override void store_current_view () {+		unowned List<ZoomView> n;+		 		if (zoom_list_index + 1 < zoom_list.length ()) {-			unowned List<ZoomView> n = zoom_list.nth (zoom_list_index);-			while (n != zoom_list.last ()) zoom_list.delete_link (zoom_list.last ());+			n = zoom_list.nth (zoom_list_index);+			while (n != zoom_list.last ()) {+				zoom_list.delete_link (zoom_list.last ());+			} 		} 		 		zoom_list.append (new ZoomView (view_offset_x, view_offset_y, view_zoom, allocation)); 		zoom_list_index = (int) zoom_list.length () - 1;-		if (zoom_list.length () > 50) zoom_list.delete_link (zoom_list.first ());+		+		if (zoom_list.length () > 50) {+			zoom_list.delete_link (zoom_list.first ());+		} 	} 	 	public override void restore_last_view () @@ -1364,7 +1374,7 @@ public class Glyph : FontDisplay { 		 		cr.save (); 		cr.new_path ();-		foreach (unowned Path p in path_list) {+		foreach (Path p in path_list) { 			if (p.stroke > 0) { 				stroke = StrokeTool.get_stroke (p, p.stroke); 				draw_path_list (stroke, cr, Color.black ());diff --git a/libbirdfont/Line.vala b/libbirdfont/Line.valaindex ed26563..37cc0cf 100644--- a/libbirdfont/Line.vala+++ b/libbirdfont/Line.vala@@ -31,9 +31,7 @@ public class Line : GLib.Object { 	 	public signal void queue_draw_area (int x, int y, int w, int h); 	public signal void position_updated (double pos);-	-	public unowned List<Line>? list_item = null;-	+		 	double r; 	double g; 	double b;diff --git a/libbirdfont/OpenFontFormat/GlyfTable.vala b/libbirdfont/OpenFontFormat/GlyfTable.valaindex d48e5b9..002d5e2 100644--- a/libbirdfont/OpenFontFormat/GlyfTable.vala+++ b/libbirdfont/OpenFontFormat/GlyfTable.vala@@ -103,7 +103,6 @@ public class GlyfTable : Table { 	public void process () throws GLib.Error { 		FontData fd = new FontData (); 		uint last_len = 0;-		uint i = 0; 		uint num_glyphs; 		 		create_glyph_table ();@@ -142,8 +141,7 @@ public class GlyfTable : Table { 		Font font = OpenFontFormatWriter.get_current_font (); 		uint32 indice; 		List<Glyph> unassigned_glyphs;-		uint32 num_glyphs = font.length ();-		uint32 i = 0;+		 		// add notdef. character at index zero + other special chars first 		glyphs.append (font.get_not_def_character ()); 		glyphs.append (font.get_null_character ());diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex 9009f7c..87f1a39 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -117,17 +117,19 @@ public class OverViewItem : GLib.Object { 		double scale_box; 		double w, h; 		double glyph_width, glyph_height;--		if (gl != null) {	+		Surface s;+		Context c;+		+		if (gl != null) { 			font = BirdFont.get_current_font (); 			w = width; 			h = height;-+			 			scale_box = (width / DEFAULT_WIDTH);-		+					 			g = ((!) gl).get_current (); 			g.boundaries (out x1, out y1, out x2, out y2);-			+		 			glyph_width = x2 - x1; 			glyph_height = y2 - y1; 			@@ -137,17 +139,19 @@ public class OverViewItem : GLib.Object { 			gx = ((w / scale) - glyph_width) / 2; 			gy = (h / scale) - 25 / scale; 			-			Surface s = new Surface.similar (cr.get_target (), Content.COLOR_ALPHA, (int) w, (int) h - 20);-			Context c = new Context (s);+			s = new Surface.similar (cr.get_target (), Content.COLOR_ALPHA, (int) w, (int) h - 20);+			c = new Context (s); 			 			c.save (); 			c.scale (scale, scale);	-			+ 			g.add_help_lines ();+			 			c.translate (gx - g.get_lsb () - Glyph.xc (), g.get_baseline () + gy - Glyph.yc ());+			 			g.draw_paths (c); 			c.restore ();-			+ 			cr.save (); 			cr.set_source_surface (s, x, y - h); 			cr.paint ();diff --git a/libbirdfont/ProgressBar.vala b/libbirdfont/ProgressBar.valadeleted file mode 100644index f0dec3b..0000000--- a/libbirdfont/ProgressBar.vala+++ /dev/null@@ -1,23 +0,0 @@-/*-    Copyright (C) 2012, 2013 Johan Mattsson--    This library is free software; you can redistribute it and/or modify -    it under the terms of the GNU Lesser General Public License as -    published by the Free Software Foundation; either version 3 of the -    License, or (at your option) any later version.--    This library is distributed in the hope that it will be useful, but -    WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -    Lesser General Public License for more details.-*/--namespace BirdFont {--// FIXME: Delete this class-class ProgressBar {-	public static void set_progress (double d) {-	}-}--}diff --git a/libbirdfont/TestBirdFont.vala b/libbirdfont/TestBirdFont.valaindex f9327fd..d87f11b 100644--- a/libbirdfont/TestBirdFont.vala+++ b/libbirdfont/TestBirdFont.vala@@ -29,11 +29,11 @@ class TestBirdFont : GLib.Object { 	unowned List<Test> test_cases;
 	unowned List<Test?>? current_case = null;
 
-	unowned List<Test> passed;
-	unowned List<Test> failed;
-	unowned List<Test> skipped;
+	List<Test> passed;
+	List<Test> failed;
+	List<Test> skipped;
 
-	unowned List<Test> bechmarks;
+	List<Test> bechmarks;
 
 	static TestBirdFont? singleton = null;
 
diff --git a/libbirdfont/TooltipArea.vala b/libbirdfont/TooltipArea.valaindex f4e6c2f..25db226 100644--- a/libbirdfont/TooltipArea.vala+++ b/libbirdfont/TooltipArea.vala@@ -86,8 +86,6 @@ public class TooltipArea : GLib.Object { 	} 	 	public void draw (Context cr, WidgetAllocation alloc) {-		int w;-		 		cr.save (); 		cr.rectangle (0, 0, alloc.width, alloc.height); 		cr.set_line_width (0);

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112