static gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
{
gchar *name1, *name2;
+ gint res;
gtk_tree_model_get(model, a, TAG_NAME, &name1, -1);
gtk_tree_model_get(model, b, TAG_NAME, &name2, -1);
if (name2 == NULL)
return 1;
- return g_utf8_collate(name1,name2);
+ res = g_utf8_collate(name1,name2);
+ g_free(name1);
+ g_free(name2);
+
+ return res;
}
static void apply_window_create(void);
if (alertpanel(_("Delete tag"),
_("Do you really want to delete this tag?"),
- GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL) != G_ALERTALTERNATE)
+ GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL,
+ ALERTFOCUS_FIRST) != G_ALERTALTERNATE)
return;
APPLYWINDOW_LOCK();
gtk_tree_model_get(model, &sel,
TAG_DATA, &id,
-1);
+
+ /* Even though this is not documented, gtk_tree_model_get()
+ * seems to invalidate the GtkTreeIter that is passed to it,
+ * so we need to reacquire it. */
+ if (!gtk_tree_selection_get_selected(selection, NULL, &sel))
+ return;
+
gtk_list_store_remove(GTK_LIST_STORE(model), &sel);
if (mainwindow_get_mainwindow() != NULL)
summaryview = mainwindow_get_mainwindow()->summaryview;
if (alertpanel(_("Delete all tags"),
_("Do you really want to delete all tags?"),
- GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL) != G_ALERTALTERNATE)
+ GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL,
+ ALERTFOCUS_FIRST) != G_ALERTALTERNATE)
return;
APPLYWINDOW_LOCK();