[totem] main: Don't use a stack-allocated GtkTreeIter
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] main: Don't use a stack-allocated GtkTreeIter
- Date: Fri, 14 Mar 2014 14:53:44 +0000 (UTC)
commit 2d601a0039151d9ce08891c9da7f794975bbd2e7
Author: Bastien Nocera <hadess hadess net>
Date: Fri Mar 14 15:44:13 2014 +0100
main: Don't use a stack-allocated GtkTreeIter
This usually won't work as expected.
src/totem-grilo.c | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/totem-grilo.c b/src/totem-grilo.c
index ca81129..079c444 100644
--- a/src/totem-grilo.c
+++ b/src/totem-grilo.c
@@ -1097,7 +1097,7 @@ find_media_cb (GtkTreeModel *model,
if (g_strcmp0 (grl_media_get_id (media), grl_media_get_id (data->media)) == 0) {
g_object_unref (media);
data->found = TRUE;
- data->iter = iter;
+ data->iter = gtk_tree_iter_copy (iter);
return TRUE;
}
g_object_unref (media);
@@ -1105,17 +1105,18 @@ find_media_cb (GtkTreeModel *model,
}
static gboolean
-find_media (GtkTreeModel *model,
- GrlMedia *media,
- GtkTreeIter *iter)
+find_media (GtkTreeModel *model,
+ GrlMedia *media,
+ GtkTreeIter **iter)
{
FindMediaData data;
data.found = FALSE;
data.media = media;
+ data.iter = NULL;
gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) find_media_cb, &data);
- *iter = *(data.iter);
+ *iter = data.iter;
return data.found;
}
@@ -1142,10 +1143,12 @@ content_changed (TotemGrilo *self,
for (i = 0; i < changed_medias->len; i++) {
GrlMedia *media = changed_medias->pdata[i];
- GtkTreeIter iter;
+ GtkTreeIter *iter;
- if (find_media (model, media, &iter))
- update_media (GTK_TREE_STORE (model), &iter, source, media);
+ if (find_media (model, media, &iter)) {
+ update_media (GTK_TREE_STORE (model), iter, source, media);
+ gtk_tree_iter_free (iter);
+ }
}
}
@@ -1161,10 +1164,13 @@ content_removed (TotemGrilo *self,
for (i = 0; i < changed_medias->len; i++) {
GrlMedia *media = changed_medias->pdata[i];
- GtkTreeIter iter;
+ GtkTreeIter *iter;
+ char *str;
- if (find_media (model, media, &iter))
- gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
+ if (find_media (model, media, &iter)) {
+ gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
+ gtk_tree_iter_free (iter);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]