Close memory leaks in ShellAppMonitor, ShellAppSystem, ShellTextureCache
Unref'ing the GdkPixbuf is particularly critical. Some smaller fixes also included.
This commit is contained in:
parent
6675b568d9
commit
4314c6e57f
@ -812,13 +812,11 @@ restore_from_file (ShellAppMonitor *monitor)
|
|||||||
/* FIXME: do something if conversion fails! */
|
/* FIXME: do something if conversion fails! */
|
||||||
/* like: errno = NULL; ... if (errno) { g_free (line); goto out; } */
|
/* like: errno = NULL; ... if (errno) { g_free (line); goto out; } */
|
||||||
}
|
}
|
||||||
else if (error)
|
else
|
||||||
{
|
{
|
||||||
g_free (line);
|
g_free (line);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
else /* End of file */
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
/* Line is about an app.
|
/* Line is about an app.
|
||||||
* If no activity was provided yet, just skip */
|
* If no activity was provided yet, just skip */
|
||||||
|
@ -145,13 +145,13 @@ reread_directories (ShellAppSystem *self, GSList **cache, GMenuTree *tree)
|
|||||||
shell_entry->icon = g_strdup (gmenu_tree_directory_get_icon (dir));
|
shell_entry->icon = g_strdup (gmenu_tree_directory_get_icon (dir));
|
||||||
|
|
||||||
*cache = g_slist_prepend (*cache, shell_entry);
|
*cache = g_slist_prepend (*cache, shell_entry);
|
||||||
|
|
||||||
gmenu_tree_item_unref (dir);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gmenu_tree_item_unref (item);
|
||||||
}
|
}
|
||||||
*cache = g_slist_reverse (*cache);
|
*cache = g_slist_reverse (*cache);
|
||||||
|
|
||||||
@ -260,13 +260,18 @@ shell_app_system_get_applications_for_menu (ShellAppSystem *monitor,
|
|||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
GMenuTreeDirectory *menu_entry;
|
GMenuTreeDirectory *menu_entry;
|
||||||
|
GSList *apps;
|
||||||
|
|
||||||
path = g_strdup_printf ("/%s", menu);
|
path = g_strdup_printf ("/%s", menu);
|
||||||
menu_entry = gmenu_tree_get_directory_from_path (monitor->priv->apps_tree, path);
|
menu_entry = gmenu_tree_get_directory_from_path (monitor->priv->apps_tree, path);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
g_assert (menu_entry != NULL);
|
g_assert (menu_entry != NULL);
|
||||||
|
|
||||||
return gather_entries_recurse (monitor, NULL, menu_entry);
|
apps = gather_entries_recurse (monitor, NULL, menu_entry);
|
||||||
|
|
||||||
|
gmenu_tree_item_unref (menu_entry);
|
||||||
|
|
||||||
|
return apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -421,7 +421,6 @@ shell_get_categories_for_desktop_file(const char *desktop_file_name)
|
|||||||
const char * const *search_dirs;
|
const char * const *search_dirs;
|
||||||
char **categories = NULL;
|
char **categories = NULL;
|
||||||
GSList *categories_list = NULL;
|
GSList *categories_list = NULL;
|
||||||
char *full_path = NULL;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gsize len;
|
gsize len;
|
||||||
int i;
|
int i;
|
||||||
@ -429,7 +428,7 @@ shell_get_categories_for_desktop_file(const char *desktop_file_name)
|
|||||||
key_file = g_key_file_new ();
|
key_file = g_key_file_new ();
|
||||||
search_dirs = get_applications_search_path();
|
search_dirs = get_applications_search_path();
|
||||||
|
|
||||||
g_key_file_load_from_dirs (key_file, desktop_file_name, (const char **)search_dirs, &full_path, 0, &error);
|
g_key_file_load_from_dirs (key_file, desktop_file_name, (const char **)search_dirs, NULL, 0, &error);
|
||||||
|
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
|
@ -188,6 +188,22 @@ typedef struct {
|
|||||||
int height;
|
int height;
|
||||||
} Dimensions;
|
} Dimensions;
|
||||||
|
|
||||||
|
static void
|
||||||
|
icon_lookup_data_destroy (gpointer p)
|
||||||
|
{
|
||||||
|
AsyncIconLookupData *data = p;
|
||||||
|
|
||||||
|
if (data->icon)
|
||||||
|
{
|
||||||
|
g_object_unref (data->icon);
|
||||||
|
gtk_icon_info_free (data->icon_info);
|
||||||
|
}
|
||||||
|
else if (data->uri)
|
||||||
|
g_free (data->uri);
|
||||||
|
|
||||||
|
g_free (data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* on_image_size_prepared:
|
* on_image_size_prepared:
|
||||||
*
|
*
|
||||||
@ -321,7 +337,7 @@ load_pixbuf_thread (GSimpleAsyncResult *result,
|
|||||||
AsyncIconLookupData *data;
|
AsyncIconLookupData *data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
data = g_simple_async_result_get_op_res_gpointer (result);
|
data = g_object_get_data (result, "load_icon_pixbuf_async");
|
||||||
|
|
||||||
if (data->uri)
|
if (data->uri)
|
||||||
pixbuf = impl_load_pixbuf_file (data->uri, data->width, data->height, &error);
|
pixbuf = impl_load_pixbuf_file (data->uri, data->width, data->height, &error);
|
||||||
@ -336,27 +352,10 @@ load_pixbuf_thread (GSimpleAsyncResult *result,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gpointer (result, g_object_ref (pixbuf),
|
g_simple_async_result_set_op_res_gpointer (result, g_object_ref (pixbuf),
|
||||||
g_object_unref);
|
g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
icon_lookup_data_destroy (gpointer p)
|
|
||||||
{
|
|
||||||
AsyncIconLookupData *data = p;
|
|
||||||
|
|
||||||
if (data->icon)
|
|
||||||
{
|
|
||||||
g_object_unref (data->icon);
|
|
||||||
gtk_icon_info_free (data->icon_info);
|
|
||||||
}
|
|
||||||
else if (data->uri)
|
|
||||||
g_free (data->uri);
|
|
||||||
|
|
||||||
g_free (data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load_icon_pixbuf_async:
|
* load_icon_pixbuf_async:
|
||||||
*
|
*
|
||||||
@ -383,8 +382,10 @@ load_icon_pixbuf_async (ShellTextureCache *cache,
|
|||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (cache), callback, user_data, load_icon_pixbuf_async);
|
result = g_simple_async_result_new (G_OBJECT (cache), callback, user_data, load_icon_pixbuf_async);
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gpointer (result, data, icon_lookup_data_destroy);
|
g_object_set_data_full (result, "load_icon_pixbuf_async", data, icon_lookup_data_destroy);
|
||||||
g_simple_async_result_run_in_thread (result, load_pixbuf_thread, G_PRIORITY_DEFAULT, cancellable);
|
g_simple_async_result_run_in_thread (result, load_pixbuf_thread, G_PRIORITY_DEFAULT, cancellable);
|
||||||
|
|
||||||
|
g_object_unref (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -407,8 +408,10 @@ load_uri_pixbuf_async (ShellTextureCache *cache,
|
|||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (cache), callback, user_data, load_uri_pixbuf_async);
|
result = g_simple_async_result_new (G_OBJECT (cache), callback, user_data, load_uri_pixbuf_async);
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gpointer (result, data, icon_lookup_data_destroy);
|
g_object_set_data_full (result, "load_uri_pixbuf_async", data, icon_lookup_data_destroy);
|
||||||
g_simple_async_result_run_in_thread (result, load_pixbuf_thread, G_PRIORITY_DEFAULT, cancellable);
|
g_simple_async_result_run_in_thread (result, load_pixbuf_thread, G_PRIORITY_DEFAULT, cancellable);
|
||||||
|
|
||||||
|
g_object_unref (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkPixbuf *
|
static GdkPixbuf *
|
||||||
@ -464,6 +467,8 @@ on_pixbuf_loaded (GObject *source,
|
|||||||
|
|
||||||
texdata = pixbuf_to_cogl_handle (pixbuf);
|
texdata = pixbuf_to_cogl_handle (pixbuf);
|
||||||
|
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
if (data->icon)
|
if (data->icon)
|
||||||
{
|
{
|
||||||
gpointer orig_key, value;
|
gpointer orig_key, value;
|
||||||
@ -619,6 +624,7 @@ shell_texture_cache_load_uri_sync (ShellTextureCache *cache,
|
|||||||
|
|
||||||
texture = CLUTTER_TEXTURE (clutter_texture_new ());
|
texture = CLUTTER_TEXTURE (clutter_texture_new ());
|
||||||
texdata = pixbuf_to_cogl_handle (pixbuf);
|
texdata = pixbuf_to_cogl_handle (pixbuf);
|
||||||
|
g_object_unref (pixbuf);
|
||||||
clutter_texture_set_cogl_texture (texture, texdata);
|
clutter_texture_set_cogl_texture (texture, texdata);
|
||||||
|
|
||||||
return CLUTTER_ACTOR (texture);
|
return CLUTTER_ACTOR (texture);
|
||||||
|
Loading…
Reference in New Issue
Block a user