summaryrefslogtreecommitdiff
path: root/gtk/gtkrecentchoosermenu.c
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@gnome.org>2011-04-06 04:43:09 +0200
committerPaolo Borelli <pborelli@gnome.org>2011-04-15 11:11:17 +0200
commit3e6af07f46c2345cd83603ed13512653310d4080 (patch)
treee5dd0830442c7d0570238a5280c7b8055f7338ff /gtk/gtkrecentchoosermenu.c
parent09efa564cb8ab9335cb722141734808c43ab8e9a (diff)
downloadgtk+-3e6af07f46c2345cd83603ed13512653310d4080.tar.gz
Free MenuPopulateData struct in all the cases.
For clarity factor out create/free functions. https://bugzilla.gnome.org/show_bug.cgi?id=646876
Diffstat (limited to 'gtk/gtkrecentchoosermenu.c')
-rw-r--r--gtk/gtkrecentchoosermenu.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/gtk/gtkrecentchoosermenu.c b/gtk/gtkrecentchoosermenu.c
index 4d61ad16a3..add5ac037c 100644
--- a/gtk/gtkrecentchoosermenu.c
+++ b/gtk/gtkrecentchoosermenu.c
@@ -969,6 +969,30 @@ typedef struct
GtkWidget *placeholder;
} MenuPopulateData;
+static MenuPopulateData *
+create_menu_populate_data (GtkRecentChooserMenu *menu)
+{
+ MenuPopulateData *pdata;
+
+ pdata = g_slice_new (MenuPopulateData);
+ pdata->items = NULL;
+ pdata->n_items = 0;
+ pdata->loaded_items = 0;
+ pdata->displayed_items = 0;
+ pdata->menu = menu;
+ pdata->placeholder = g_object_ref (menu->priv->placeholder);
+
+ return pdata;
+}
+
+static void
+free_menu_populate_data (MenuPopulateData *pdata)
+{
+ if (pdata->placeholder)
+ g_object_unref (pdata->placeholder);
+ g_slice_free (MenuPopulateData, pdata);
+}
+
static gboolean
idle_populate_func (gpointer data)
{
@@ -1056,10 +1080,9 @@ idle_populate_clean_up (gpointer data)
*/
if (!pdata->displayed_items)
gtk_widget_show (pdata->placeholder);
- g_object_unref (pdata->placeholder);
-
- g_slice_free (MenuPopulateData, data);
}
+
+ free_menu_populate_data (pdata);
}
static void
@@ -1068,20 +1091,14 @@ gtk_recent_chooser_menu_populate (GtkRecentChooserMenu *menu)
MenuPopulateData *pdata;
GtkRecentChooserMenuPrivate *priv = menu->priv;
- if (menu->priv->populate_id)
+ if (priv->populate_id)
return;
- pdata = g_slice_new (MenuPopulateData);
- pdata->items = NULL;
- pdata->n_items = 0;
- pdata->loaded_items = 0;
- pdata->displayed_items = 0;
- pdata->menu = menu;
- pdata->placeholder = g_object_ref (priv->placeholder);
+ pdata = create_menu_populate_data (menu);
/* remove our menu items first */
gtk_recent_chooser_menu_dispose_items (menu);
-
+
priv->populate_id = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE + 30,
idle_populate_func,
pdata,