Commit a9b4458
Merge pull request #132 from boen1977/wrncleanup Remove compiler warnings: `GLib.Thread.create'
Changed files (11)
modifiedbirdfont-test/TestRunner.valamodifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/BirdFont.valamodifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/OpenFontFormat/load_font.cmodifiedlibbirdfont/Renderer/Text.valamodifiedlibbirdfont/Renderer/fontconfig.cmodifiedlibbirdfont/ResizeTool.valamodifiedlibbirdfont/SearchPaths.valamodifiedlibbirdfont/StrokeTool.vala
Diff
@@ -221,7 +221,7 @@ public class TestRunner : NativeWindow, GLib.Object { MenuTab.start_background_thread (); try {- bg = Thread.create<void*> (t.perform_task, true);+ bg = new Thread<void*>.try ("bg", t.perform_task); } catch (GLib.Error e) { warning (e.message); }@@ -231,7 +231,7 @@ public class TestRunner : NativeWindow, GLib.Object { unowned Thread<void*> bg; try {- bg = Thread.create<void*> (t.perform_task, true);+ bg = new Thread<void*>.try ("bg", t.perform_task); } catch (GLib.Error e) { warning (e.message); }@@ -81,12 +81,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { uri = Preview.get_uri (); html = Preview.get_html_with_absolute_paths (); - try { - html_canvas.load_html (html, uri);- } catch (Error e) {- warning (e.message);- warning ("Failed to load html into canvas.");- }+ html_canvas.load_html (html, uri); // show the webview when loading has finished html_box.set_visible (true); @@ -331,16 +326,16 @@ public class GtkWindow : Gtk.Window, NativeWindow { } else { if ((flags & FileChooser.DIRECTORY) > 0) { if ((flags & FileChooser.LOAD) > 0) {- fn = show_file_chooser (title, FileChooserAction.SELECT_FOLDER, Stock.OPEN);+ fn = show_file_chooser (title, FileChooserAction.SELECT_FOLDER, t_("Open")); } else if ((flags & FileChooser.SAVE) > 0) {- fn = show_file_chooser (title, FileChooserAction.SELECT_FOLDER, Stock.SAVE);+ fn = show_file_chooser (title, FileChooserAction.SELECT_FOLDER, t_("Save")); } else { warning ("Open or save is not set."); } } else if ((flags & FileChooser.LOAD) > 0) {- fn = show_file_chooser (title, FileChooserAction.OPEN, Stock.OPEN);+ fn = show_file_chooser (title, FileChooserAction.OPEN, t_("Open")); } else if ((flags & FileChooser.SAVE) > 0) {- fn = show_file_chooser (title, FileChooserAction.SAVE, Stock.SAVE);+ fn = show_file_chooser (title, FileChooserAction.SAVE, t_("Save")); } else { warning ("Unknown type"); }@@ -351,7 +346,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { public string? show_file_chooser (string title, FileChooserAction action, string label) { string? fn = null;- FileChooserDialog file_chooser = new FileChooserDialog (title, this, action, Stock.CANCEL, ResponseType.CANCEL, label, ResponseType.ACCEPT);+ FileChooserDialog file_chooser = new FileChooserDialog (title, this, action, t_("Cancel"), ResponseType.CANCEL, label, ResponseType.ACCEPT); Font font = BirdFont.get_current_font (); int i; string last_folder;@@ -415,7 +410,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { background_task = t; try {- bg = Thread.create<void*> (this.background_thread, true);+ bg = new Thread<void*>.try ("bg", this.background_thread); } catch (GLib.Error e) { warning (e.message); }@@ -425,7 +420,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { unowned Thread<void*> bg; try {- bg = Thread.create<void*> (t.perform_task, true);+ bg = new Thread<void*>.try ("bg", t.perform_task); } catch (GLib.Error e) { warning (e.message); }@@ -444,7 +439,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { MenuTab.start_background_thread (); try {- export_thread = Thread.create<void*> (this.export_thread, true);+ export_thread = new Thread<void*>.try ("export_thread", this.export_thread); } catch (GLib.Error e) { warning (e.message); }@@ -460,7 +455,11 @@ public class GtkWindow : Gtk.Window, NativeWindow { idle.set_callback (() => { Notify.Notification export_notification; export_notification = new Notify.Notification ("BirdFont", t_("Your fonts have been exported."), null);- export_notification.show ();+ try {+ export_notification.show ();+ } catch (GLib.Error e) {+ warning (e.message);+ } return false; }); idle.attach (null);@@ -475,7 +474,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { MenuTab.start_background_thread (); try {- thread = Thread.create<void*> (this.loading_thread, true);+ thread = new Thread<void*>.try ("thread", this.loading_thread); } catch (GLib.Error e) { warning (e.message); }@@ -495,7 +494,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { MenuTab.start_background_thread (); try {- thread = Thread.create<void*> (this.saving_thread, true);+ thread = new Thread<void*>.try ("thread", this.saving_thread); } catch (GLib.Error e) { warning (e.message); }@@ -514,7 +513,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { MenuTab.start_background_thread (); try {- thread = Thread.create<void*> (this.background_image_thread, true);+ thread = new Thread<void*>.try ("thread", this.background_image_thread); } catch (GLib.Error e) { warning (e.message); }@@ -576,9 +575,9 @@ class TabbarCanvas : DrawingArea { draw.connect ((t, e)=> { Gtk.Allocation alloc;- Context cr; + Context cr = e; - cr = cairo_create ((!) get_window ());+ //cr = cairo_create ((!) get_window ()); get_allocation (out alloc); tabbar.draw (cr, alloc.width, alloc.height);@@ -642,7 +641,8 @@ class ToolboxCanvas : DrawingArea { Gtk.Allocation allocation; get_allocation (out allocation); - Context cw = cairo_create((!) get_window());+ Context cw = e;+ //cw = cairo_create((!) get_window()); Toolbox.allocation_width = allocation.width; Toolbox.allocation_height = allocation.height; tb.draw (allocation.width, allocation.height, cw);@@ -705,7 +705,8 @@ public class GlyphCanvasArea : DrawingArea { alloc.x = allocation.x; alloc.y = allocation.y; - Context cw = cairo_create ((!) get_window());+ Context cw = e;+ //cw = cairo_create ((!) get_window()); Surface s = new Surface.similar (cw.get_target (), Cairo.Content.COLOR_ALPHA, alloc.width, alloc.height); Context c = new Context (s); @@ -294,7 +294,7 @@ public class BirdFont { #endif } - public static void load_font_from_command_line () {+ public void load_font_from_command_line () { string file = args.get_file (); if (file != "") { RecentFiles.load_font (file);@@ -29,7 +29,7 @@ class BirdFontFile : GLib.Object { public const int MIN_FORMAT_MAJOR = 0; public const int MIN_FORMAT_MINOR = 0; - public bool has_svg_glyphs = false; + //public bool has_svg_glyphs = false; Gee.ArrayList<string> written_images = new Gee.ArrayList<string> (); @@ -459,7 +459,11 @@ os.put_string ( } string html_data;- FileUtils.get_contents ((!) template.get_path (), out html_data);+ try {+ FileUtils.get_contents ((!) template.get_path (), out html_data);+ } catch (FileError e) {+ warning (e.message);+ } string name; #if MAC @@ -631,7 +635,7 @@ os.put_string ( critical (@"$(e.message)"); } }- + /* static bool can_write (File folder) { File test = get_child (folder, "text.tmp"); bool writable = false;@@ -648,6 +652,7 @@ os.put_string ( return writable; }+ */ } }@@ -131,7 +131,7 @@ void create_contour (guint unicode, FT_Vector* points, char* flags, int* length, int j; guint prev_is_curve; guint first_is_curve = FALSE;- guint first_normal_off_curve = FALSE;+ //guint first_normal_off_curve = FALSE; double x = 0; double y = 0; FT_Vector* p;@@ -172,7 +172,7 @@ void create_contour (guint unicode, FT_Vector* points, char* flags, int* length, // first point is of curve but it is not part of a double curve if (len > 2 && is_quadratic (flags[0]) && !is_quadratic (flags[1])) { - first_normal_off_curve = TRUE;+ //first_normal_off_curve = TRUE; } while (i < len) {@@ -380,19 +380,19 @@ GString* get_bf_contour_data (guint unicode, FT_Vector* points, char* flags, int gchar coordinate_buffer[80]; gchar* coordinate = (gchar*) &coordinate_buffer; double units = get_units (units_per_em);- guint prev_is_curve;- int points_length;+ //guint prev_is_curve;+ //int points_length; if (length == 0) { return bf; } - points_length = length;+ //points_length = length; - gboolean last_to_first = FALSE;+ //gboolean last_to_first = FALSE; - int last_x = 0;- int last_y = 0;+ //int last_x = 0;+ //int last_y = 0; create_contour (unicode, points, flags, &length, &new_points, &new_flags, err); @@ -454,8 +454,8 @@ GString* get_bf_contour_data (guint unicode, FT_Vector* points, char* flags, int g_ascii_formatd (coordinate, 80, "%f", y2); g_string_append (contour, coordinate); - last_x = new_points[i+2].x;- last_y = new_points[i+2].y;+ //last_x = new_points[i+2].x;+ //last_y = new_points[i+2].y; i += 3; } else if (is_double_curve (new_flags[i])) {@@ -491,8 +491,8 @@ GString* get_bf_contour_data (guint unicode, FT_Vector* points, char* flags, int g_ascii_formatd (coordinate, 80, "%f", y2); g_string_append (contour, coordinate); - last_x = new_points[i+2].x;- last_y = new_points[i+2].y;+ //last_x = new_points[i+2].x;+ //last_y = new_points[i+2].y; i += 3; } else if (is_quadratic (new_flags[i])) {@@ -518,8 +518,8 @@ GString* get_bf_contour_data (guint unicode, FT_Vector* points, char* flags, int g_ascii_formatd (coordinate, 80, "%f", y1); g_string_append (contour, coordinate); - last_x = new_points[i + 1].x;- last_y = new_points[i + 1].y;+ //last_x = new_points[i + 1].x;+ //last_y = new_points[i + 1].y; i += 2; } else if (is_line (new_flags[i])) {@@ -537,8 +537,8 @@ GString* get_bf_contour_data (guint unicode, FT_Vector* points, char* flags, int i += 1; - last_x = new_points[i].x;- last_y = new_points[i].y;+ //last_x = new_points[i].x;+ //last_y = new_points[i].y; } else { contour = g_string_new (""); g_warning ("Can't parse outline.\n");@@ -560,7 +560,7 @@ GString* get_bf_contour_data (guint unicode, FT_Vector* points, char* flags, int GString* get_bf_path (guint unicode, FT_Face face, double units_per_em, int* err) { GString* bf = g_string_new (""); GString* contour;- FT_Error error;+ //FT_Error error; int i; int start; int end;@@ -593,7 +593,7 @@ FreeTypeFontFace* open_font (const gchar* file) { return NULL; } - gchar* short_path = file;+ gchar* short_path = (gchar *)file; error = FT_New_Face (library, short_path, 0, &face); @@ -807,7 +807,7 @@ void append_description (GString* str, FT_SfntName* name_table_data) { GError* error = NULL; if (name_table_data->encoding_id == 0) { // mac roman- utf8_str = g_convert (name_table_data->string, name_table_data->string_len, "utf-8", "macintosh", &read, &written, &error);+ utf8_str = g_convert ((const gchar *)name_table_data->string, name_table_data->string_len, "utf-8", "macintosh", &read, &written, &error); if (error == NULL) { g_string_append (str, g_markup_escape_text (utf8_str, -1));@@ -817,7 +817,7 @@ void append_description (GString* str, FT_SfntName* name_table_data) { g_error_free (error); } } else if (name_table_data->encoding_id == 1) { // windows unicode- utf8_str = g_convert (name_table_data->string, name_table_data->string_len, "utf-8", "ucs-2be", &read, &written, &error);+ utf8_str = g_convert ((const gchar *)name_table_data->string, name_table_data->string_len, "utf-8", "ucs-2be", &read, &written, &error); if (error == NULL) { g_string_append (str, g_markup_escape_text (utf8_str, -1));@@ -867,10 +867,10 @@ int getIndexForNameId (FT_Face face, int id) { * @param err error code * @return xml representation of a bf font */-GString* get_bf_font (FT_Face face, char* file, int* err) {+GString* get_bf_font (FT_Face face, const char* file, int* err) { GString* bf = g_string_new (""); GString* bf_data;- gchar* kerning;+ //gchar* kerning; GString* glyph; FT_Error error; FT_Long i;@@ -1052,7 +1052,8 @@ GString* get_bf_font (FT_Face face, char* file, int* err) { g_string_append_printf (bf, "<collection unicode=\"U+20\">\n"); g_string_append_printf (bf, "\t<glyph left=\"%f\" right=\"%f\" selected=\"true\">\n", 0.0, face->glyph->metrics.horiAdvance * units); - bf_data = get_bf_path (charcode, face, units_per_em, err);+ //bf_data = get_bf_path (charcode, face, units_per_em, err);+ bf_data = get_bf_path (' ', face, units_per_em, err); g_string_append (bf, bf_data->str); g_string_append (bf, "\t</glyph>\n");@@ -1101,7 +1102,7 @@ GString* get_bf_font (FT_Face face, char* file, int* err) { } if (!has_unicode_value) {- g_warning ("Ignoring glyph without a Unicode value, %d. (condition: %d)", + g_warning ("Ignoring glyph without a Unicode value, %ld. (condition: %d)", i, has_unicode_value); break; }@@ -1158,8 +1159,8 @@ GString* load_freetype_font (const gchar* file, gint* err) { FT_Library library; FT_Face face; int error;- FT_Glyph glyph;- FT_UInt glyph_index;+ //FT_Glyph glyph;+ //FT_UInt glyph_index; error = FT_Init_FreeType (&library); if (error != OK) {@@ -1186,7 +1187,7 @@ GString* load_freetype_font (const gchar* file, gint* err) { // not tested the new code. gchar* short_path = calloc ((2048 + 1), sizeof(gchar));- short_path = file;+ short_path = (gchar *)file; error = FT_New_Face (library, short_path, 0, &face); if (error) {@@ -1244,13 +1245,13 @@ gboolean get_freetype_font_is_regular (const char* file) { FT_Library library = NULL; FT_Face face = NULL; int error;- FreeTypeFontFace* font;+ FreeTypeFontFace* font = NULL; error = FT_Init_FreeType (&library); if (error != OK) { g_warning ("Freetype init error %d.\n", error);- return NULL;+ return FALSE; } gchar* short_path = calloc ((2048 + 1), sizeof(gchar));@@ -1267,7 +1268,7 @@ gboolean get_freetype_font_is_regular (const char* file) { g_warning ("Can't open file %s", file); g_warning ("Short path: %s", short_path); - return NULL;+ return FALSE; } if (font == NULL || font->face == NULL || font->library == NULL) {@@ -1280,7 +1281,7 @@ gboolean get_freetype_font_is_regular (const char* file) { } gulong* get_all_unicode_points_in_font (const gchar* file) {- FT_ULong* charcodes = NULL;+ //FT_ULong* charcodes = NULL; FT_Library library; FT_Face face; @@ -1322,7 +1323,7 @@ gulong* get_all_unicode_points_in_font (const gchar* file) { } gboolean error_in_result = FALSE;- gint gindex = 0;+ FT_UInt gindex = 0; FT_ULong charcode; gint num_glyphs = 0; @@ -1371,4 +1372,4 @@ gulong* get_all_unicode_points_in_font (const gchar* file) { FT_Done_FreeType (library); return result;-}\ No newline at end of file+}@@ -389,7 +389,7 @@ public class Text : Widget { // double x = margin_left * ratio; double x = 0;- double py = cc_y;+ //double py = cc_y; double w = get_sidebearing_extent () * screen_scale + x + margin_left + 1; @@ -111,7 +111,7 @@ gchar* find_font_file (FcConfig* font_config, const gchar* font_name) { } path = NULL;- name = font_name;+ name = (FcChar8*) font_name; search_pattern = FcPatternCreate (); FcPatternAddString (search_pattern, FC_FAMILY, name);@@ -479,7 +479,7 @@ public class ResizeTool : Tool { objects_resized (selection_box_width, selection_box_height); }-+ /* void get_selection_min (out double x, out double y) { Glyph glyph = MainWindow.get_current_glyph (); x = double.MAX;@@ -494,7 +494,7 @@ public class ResizeTool : Tool { } } }-+ */ bool can_resize (double x, double y) { Glyph glyph = MainWindow.get_current_glyph (); double h, w;@@ -37,8 +37,13 @@ public class SearchPaths { resources = (is_null (resources_folder)) ? "" : resources_folder; - string? current_program = GLib.FileUtils.read_link ("/proc/self/exe"); -+ string? current_program;+ try {+ current_program = GLib.FileUtils.read_link ("/proc/self/exe");+ } catch (Error e) {+ warning (e.message);+ current_program = null;+ } if (current_program != null) { string program = (!) current_program; int separator = program.last_index_of ("/");@@ -1451,7 +1451,7 @@ public class StrokeTool : GLib.Object { return intersections; }- + /* bool split_corner (PathList pl) { EditPoint p1, p2; EditPoint a1, a2;@@ -1513,7 +1513,8 @@ public class StrokeTool : GLib.Object { return false; }-+ */+ /* bool split_segment (Path p, EditPoint first, EditPoint next, EditPoint p1, EditPoint p2, out PathList result) { double ix, iy; bool intersection;@@ -1534,7 +1535,7 @@ public class StrokeTool : GLib.Object { return intersection; }- + */ PathList get_parts_self (Path path, PathList? paths = null) { PathList pl; PathList r;@@ -1899,6 +1900,7 @@ public class StrokeTool : GLib.Object { } // indside becomes outside in some paths+ /* void remove_points_in_stroke (PathList pl) { PathList r; @@ -1910,7 +1912,8 @@ public class StrokeTool : GLib.Object { } } }-+ */+ /* bool remove_points_in_stroke_for_path (Path p, PathList pl, out PathList result) { EditPoint start_ep; EditPoint start_next;@@ -1950,7 +1953,8 @@ public class StrokeTool : GLib.Object { return false; }-+ */+ /* bool merge_segments (PathList pl, Path path1, EditPoint start1, EditPoint stop1, EditPoint start2, EditPoint stop2,@@ -2022,7 +2026,7 @@ public class StrokeTool : GLib.Object { return false; }-+ */ void reset_intersections (Path p) { foreach (EditPoint ep in p.points) { ep.flags &= ~EditPoint.INTERSECTION;@@ -2032,7 +2036,7 @@ public class StrokeTool : GLib.Object { } p.remove_points_on_points (); }-+ /* bool add_merge_intersection_point (Path path1, Path path2, EditPoint first, EditPoint next) { double ix, iy; bool intersection;@@ -2058,7 +2062,7 @@ public class StrokeTool : GLib.Object { return intersection; }- + */ bool is_inside_of_path (PointSelection ps, PathList pl, out Path outline) { outline = new Path (); foreach (Path p in pl.paths) {