r23049 - gnucash/trunk/src/gnome-utils - Register2: Add more sanity checks when converting TreePaths from one to another.

Christian Stimming cstim at code.gnucash.org
Thu Jun 13 16:25:13 EDT 2013


Author: cstim
Date: 2013-06-13 16:25:12 -0400 (Thu, 13 Jun 2013)
New Revision: 23049
Trac: http://svn.gnucash.org/trac/changeset/23049

Modified:
   gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
Log:
Register2: Add more sanity checks when converting TreePaths from one to another.

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c	2013-06-13 07:58:49 UTC (rev 23048)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c	2013-06-13 20:25:12 UTC (rev 23049)
@@ -410,7 +410,9 @@
     return FALSE;
 }
 
-/* Get sort model path from the model path */
+/* Get sort model path from the model path
+ *
+ * \return A newly allocated GtkTreePath, or NULL */
 GtkTreePath *
 gnc_tree_view_split_reg_get_sort_path_from_model_path (GncTreeViewSplitReg *view, GtkTreePath *mpath)
 {
@@ -421,6 +423,7 @@
     f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
 
     fpath = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model), mpath);
+    g_return_val_if_fail(fpath, NULL);
 
     spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model), fpath);
 
@@ -429,17 +432,25 @@
     return spath;
 }
 
-/* Get model path from the sort model path */
+/* Get model path from the sort model path
+ *
+ * \return A newly allocated GtkTreePath, or NULL. */
 GtkTreePath *
 gnc_tree_view_split_reg_get_model_path_from_sort_path (GncTreeViewSplitReg *view, GtkTreePath *spath)
 {
     GtkTreeModel *f_model, *s_model;
     GtkTreePath *fpath, *mpath;
+    g_return_val_if_fail(spath, NULL);
 
     s_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
     f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
 
     fpath = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (s_model), spath);
+    if (!fpath)
+    {
+        /* No child path available */
+        return NULL;
+    }
 
     mpath = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (f_model), fpath);
 
@@ -5736,10 +5747,12 @@
 }
 
 
-/* Returns the current path */
+/* Returns the current path, or NULL if the current path is the blank split. */
 GtkTreePath *
 gnc_tree_view_split_reg_get_current_path (GncTreeViewSplitReg *view)
 {
+    if (!view->priv->current_ref)
+        return NULL;
     return gtk_tree_row_reference_get_path (view->priv->current_ref);
 }
 



More information about the gnucash-changes mailing list