gnucash maint: Ensure that the Namespace combo box is initialized to a valid iter.

John Ralls jralls at code.gnucash.org
Thu Nov 10 16:58:19 EST 2016


Updated	 via  https://github.com/Gnucash/gnucash/commit/32c4d145 (commit)
	from  https://github.com/Gnucash/gnucash/commit/5fcdfba6 (commit)



commit 32c4d1458870bdbcdbed1b47f23c2957af1f8f3d
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Nov 10 13:56:09 2016 -0800

    Ensure that the Namespace combo box is initialized to a valid iter.
    
    Thanks to David T. for noticing that it wasn't.

diff --git a/src/gnome-utils/dialog-commodity.c b/src/gnome-utils/dialog-commodity.c
index ca3c564..a30ffd6 100644
--- a/src/gnome-utils/dialog-commodity.c
+++ b/src/gnome-utils/dialog-commodity.c
@@ -646,6 +646,7 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe,
     GtkTreeModel *model;
     GtkTreeIter iter, match;
     GList *namespaces, *node;
+    gboolean matched = FALSE;
 
     g_return_if_fail(GTK_IS_COMBO_BOX (cbwe));
 
@@ -653,8 +654,6 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe,
     combo_box = GTK_COMBO_BOX(cbwe);
     model = gtk_combo_box_get_model(combo_box);
     gtk_list_store_clear(GTK_LIST_STORE(model));
-    gtk_tree_model_get_iter_first(model, &match);
-    gtk_combo_box_set_active_iter(combo_box, &match);
 
     /* fetch a list of the namespaces */
     switch (mode)
@@ -698,9 +697,14 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe,
         }
 
         if (init_string && (g_utf8_collate(node->data, init_string) == 0))
+        {
+            matched = TRUE;
             match = iter;
+        }
     }
 
+    if (!matched)
+        gtk_tree_model_get_iter_first(model, &match);
     gtk_combo_box_set_active_iter(combo_box, &match);
     g_list_free(namespaces);
 }



Summary of changes:
 src/gnome-utils/dialog-commodity.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)



More information about the gnucash-changes mailing list