fix another leak, an invalid free, and a simplify error handling

2008-11-18  Jens Granseuer  <jensgr@gmx.net>

	* font-viewer/font-view.c: (add_face_info), (set_icon):
	* font-viewer/ftstream-vfs.c: (vfs_stream_open): fix another
	leak, an invalid free, and a simplify error handling

svn path=/trunk/; revision=9144
This commit is contained in:
Jens Granseuer 2008-11-18 20:04:02 +00:00 committed by Jens Granseuer
parent afbe70bca0
commit cabbecfa4b
3 changed files with 18 additions and 14 deletions

View file

@ -1,3 +1,9 @@
2008-11-18 Jens Granseuer <jensgr@gmx.net>
* font-viewer/font-view.c: (add_face_info), (set_icon):
* font-viewer/ftstream-vfs.c: (vfs_stream_open): fix another
leak, an invalid free, and a simplify error handling
2008-11-18 Rodrigo Moya <rodrigo@gnome-db.org> 2008-11-18 Rodrigo Moya <rodrigo@gnome-db.org>
* font-viewer/font-view.c (set_icon): don't leak icon_name. * font-viewer/font-view.c (set_icon): don't leak icon_name.

View file

@ -157,7 +157,7 @@ create_text_pixmap(GtkWidget *drawing_area, FT_Face face)
/* calculate size of pixmap to use (with 4 pixels padding) ... */ /* calculate size of pixmap to use (with 4 pixels padding) ... */
pixmap_width = 8; pixmap_width = 8;
pixmap_height = 8; pixmap_height = 8;
font = get_font(xdisplay, face, alpha_size, charset); font = get_font(xdisplay, face, alpha_size, charset);
charset = FcCharSetCopy (font->charset); charset = FcCharSetCopy (font->charset);
XftTextExtentsUtf8(xdisplay, font, XftTextExtentsUtf8(xdisplay, font,
@ -284,6 +284,7 @@ add_face_info(GtkWidget *table, gint *row_p, const gchar *uri, FT_Face face)
G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_ATTRIBUTE_STANDARD_SIZE,
G_FILE_QUERY_INFO_NONE, G_FILE_QUERY_INFO_NONE,
NULL, NULL); NULL, NULL);
g_object_unref (file);
if (info) { if (info) {
s = g_content_type_get_description (g_file_info_get_content_type (info)); s = g_content_type_get_description (g_file_info_get_content_type (info));
@ -297,8 +298,6 @@ add_face_info(GtkWidget *table, gint *row_p, const gchar *uri, FT_Face face)
g_object_unref (info); g_object_unref (info);
} }
g_object_unref (file);
if (FT_IS_SFNT(face)) { if (FT_IS_SFNT(face)) {
gint i, len; gint i, len;
gchar *version = NULL, *copyright = NULL, *description = NULL; gchar *version = NULL, *copyright = NULL, *description = NULL;
@ -376,7 +375,7 @@ set_icon(GtkWindow *window, const gchar *uri)
GFileInfo *info; GFileInfo *info;
GdkScreen *screen; GdkScreen *screen;
GtkIconTheme *icon_theme; GtkIconTheme *icon_theme;
gchar *icon_name = NULL, *content_type = NULL; const gchar *icon_name = NULL, *content_type;
screen = gtk_widget_get_screen (GTK_WIDGET (window)); screen = gtk_widget_get_screen (GTK_WIDGET (window));
icon_theme = gtk_icon_theme_get_for_screen (screen); icon_theme = gtk_icon_theme_get_for_screen (screen);
@ -385,10 +384,10 @@ set_icon(GtkWindow *window, const gchar *uri)
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
G_FILE_QUERY_INFO_NONE, NULL, NULL); G_FILE_QUERY_INFO_NONE, NULL, NULL);
if (! info) { g_object_unref (file);
g_object_unref (file);
if (! info)
return; return;
}
content_type = g_file_info_get_content_type (info); content_type = g_file_info_get_content_type (info);
icon = g_content_type_get_icon (content_type); icon = g_content_type_get_icon (content_type);
@ -399,21 +398,20 @@ set_icon(GtkWindow *window, const gchar *uri)
names = g_themed_icon_get_names (G_THEMED_ICON (icon)); names = g_themed_icon_get_names (G_THEMED_ICON (icon));
if (names) { if (names) {
gint i; gint i;
for (i = 0; names[i]; i++) for (i = 0; names[i]; i++) {
if (gtk_icon_theme_has_icon (icon_theme, names[i])) { if (gtk_icon_theme_has_icon (icon_theme, names[i])) {
icon_name = g_strdup (names[i]); icon_name = names[i];
break; break;
} }
}
} }
} }
if (icon_name) { if (icon_name) {
gtk_window_set_icon_name (window, icon_name); gtk_window_set_icon_name (window, icon_name);
g_free (icon_name);
} }
g_object_unref (icon); g_object_unref (icon);
g_free (content_type);
} }
int int
@ -449,7 +447,7 @@ main(int argc, char **argv)
if (error) { if (error) {
g_printerr("could not initialise freetype\n"); g_printerr("could not initialise freetype\n");
return 1; return 1;
} }
file = g_file_new_for_commandline_arg (argv[1]); file = g_file_new_for_commandline_arg (argv[1]);
font_file = g_file_get_uri (file); font_file = g_file_get_uri (file);

View file

@ -89,17 +89,17 @@ vfs_stream_open(FT_Stream stream,
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
G_FILE_QUERY_INFO_NONE, NULL, &error); G_FILE_QUERY_INFO_NONE, NULL, &error);
g_object_unref (file);
if (! info) { if (! info) {
g_warning (error->message); g_warning (error->message);
g_error_free (error); g_error_free (error);
g_object_unref (file);
return FT_Err_Cannot_Open_Resource; return FT_Err_Cannot_Open_Resource;
} }
stream->size = g_file_info_get_size (info); stream->size = g_file_info_get_size (info);
g_object_unref (file);
g_object_unref (info); g_object_unref (info);
stream->descriptor.pointer = handle; stream->descriptor.pointer = handle;