diff mbox

[1/2] test-inspect: handle special case iter==NULL

Message ID CANeU7QnP1afR6ey0Zu1tkoGFGYcCWGaA-Oc1+mbDJdHNSTk1qQ@mail.gmail.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Christopher Li Aug. 10, 2017, 9:02 p.m. UTC
GtkTreeView has this special case that iter==NULL means the
root node.

Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
---
 ast-model.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/ast-model.c b/ast-model.c
index 63d2762..cbd82db 100644
--- a/ast-model.c
+++ b/ast-model.c
@@ -401,7 +401,8 @@  static gint
 ast_iter_n_children (GtkTreeModel *tree_model,
                           GtkTreeIter  *iter)
 {
- AstNode  *node = iter->user_data;
+ AstNode  *node = iter ? iter->user_data
+ : AST_NODE(tree_model);

  inspect_child_node(node);
  return node->childnodes->len;