Commit b0d888a
Fix memory leak
Changed files (9)
modifiedlibbirdfont/Argument.valamodifiedlibbirdfont/CharDatabaseParser.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/Line.valamodifiedlibbirdfont/OpenFontFormat/GlyfTable.valamodifiedlibbirdfont/OverViewItem.valadeletedlibbirdfont/ProgressBar.valamodifiedlibbirdfont/TestBirdFont.valamodifiedlibbirdfont/TooltipArea.vala
Diff
@@ -71,7 +71,7 @@ public class Argument : GLib.Object { a == "--mac" || a == "--android" || a == "--log" ||- a == "--donated") {+ a == "--no-ucd") { prev = a; i++; continue;@@ -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 {@@ -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 ());@@ -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;@@ -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 ());@@ -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 ();deleted file mode 100644@@ -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) {- }-}--}@@ -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; @@ -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);