Clone in a terminal:
Commit a9b4458
Johan Mattsson - 2022-04-11T19:18:03+00:00
a9b4458b3f1da17337753381e4092c7606168996johan.mattsson.m@gmail.com

Merge pull request #132 from boen1977/wrncleanup Remove compiler warnings: `GLib.Thread.create'

Changed files (11)

Diff

diff --git a/birdfont-test/TestRunner.vala b/birdfont-test/TestRunner.valaindex 96d39cd..0b36af1 100644--- a/birdfont-test/TestRunner.vala+++ b/birdfont-test/TestRunner.vala@@ -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); 		}diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex 1235ffd..bea720a 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -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); diff --git a/libbirdfont/BirdFont.vala b/libbirdfont/BirdFont.valaindex dc215db..31bc0a2 100644--- a/libbirdfont/BirdFont.vala+++ b/libbirdfont/BirdFont.vala@@ -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);diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex fedbf76..5df6275 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -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> (); 		diff --git a/libbirdfont/ExportTool.vala b/libbirdfont/ExportTool.valaindex bbe31b1..5b12df2 100644--- a/libbirdfont/ExportTool.vala+++ b/libbirdfont/ExportTool.vala@@ -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; 	}+	*/ }  }diff --git a/libbirdfont/OpenFontFormat/load_font.c b/libbirdfont/OpenFontFormat/load_font.cindex d85a728..b71ea12 100644--- a/libbirdfont/OpenFontFormat/load_font.c+++ b/libbirdfont/OpenFontFormat/load_font.c@@ -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+}diff --git a/libbirdfont/Renderer/Text.vala b/libbirdfont/Renderer/Text.valaindex fcaa8a3..9187729 100644--- a/libbirdfont/Renderer/Text.vala+++ b/libbirdfont/Renderer/Text.vala@@ -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; 		diff --git a/libbirdfont/Renderer/fontconfig.c b/libbirdfont/Renderer/fontconfig.cindex f02b747..1a07874 100644--- a/libbirdfont/Renderer/fontconfig.c+++ b/libbirdfont/Renderer/fontconfig.c@@ -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);diff --git a/libbirdfont/ResizeTool.vala b/libbirdfont/ResizeTool.valaindex aad972e..22fffd0 100644--- a/libbirdfont/ResizeTool.vala+++ b/libbirdfont/ResizeTool.vala@@ -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;diff --git a/libbirdfont/SearchPaths.vala b/libbirdfont/SearchPaths.valaindex f7afdf8..e7d03ef 100644--- a/libbirdfont/SearchPaths.vala+++ b/libbirdfont/SearchPaths.vala@@ -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 ("/");diff --git a/libbirdfont/StrokeTool.vala b/libbirdfont/StrokeTool.valaindex 6476018..ed8f4eb 100644--- a/libbirdfont/StrokeTool.vala+++ b/libbirdfont/StrokeTool.vala@@ -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) {

Contact

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