TreeModel HAS_CHILD return

View: New views
6 Messages — Rating Filter:   Alert me  

TreeModel HAS_CHILD return

by Kevin Ryde :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

When implementing HAS_CHILD for a TreeModel, I tried to return a string
or undef as my boolean but got an error,

    Argument "\x{5e}\x{41}..." isn't numeric in subroutine entry at t-symlist-model.pl line 18.

gtk2perl_tree_model_iter_has_child looks like it uses POPi.  Could it
test the return with sv_true (or whichever test it is that correctly
handles magic)?
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: TreeModel HAS_CHILD return

by Torsten Schoenfeld :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kevin Ryde wrote:

> gtk2perl_tree_model_iter_has_child looks like it uses POPi.  Could it
> test the return with sv_true (or whichever test it is that correctly
> handles magic)?

Yes, I think that would make sense.  Patch attached.  Does this work in
your case?

--
Bye,
-Torsten

Index: t/GtkTreeModelIface.t
===================================================================
RCS file: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/GtkTreeModelIface.t,v
retrieving revision 1.5
diff -u -d -p -r1.5 GtkTreeModelIface.t
--- t/GtkTreeModelIface.t 5 Oct 2005 19:13:07 -0000 1.5
+++ t/GtkTreeModelIface.t 4 May 2008 13:11:48 -0000
@@ -180,7 +180,7 @@ sub ITER_HAS_CHILD {
  isa_ok ($list, "CustomList", "ITER_HAS_CHILD");
  ok ($iter->[0] == $list->{stamp}, "ITER_HAS_CHILD");
 
- return FALSE;
+ return 'asdf';
 }
 
 sub ITER_N_CHILDREN {
@@ -374,7 +374,7 @@ isa_ok ($iter = $model->iter_children(un
 isa_ok ($path = $model->get_path ($iter), "Gtk2::TreePath");
 is_deeply ([$path->get_indices], [0]);
 
-is ($model->iter_has_child ($iter), FALSE);
+is ($model->iter_has_child ($iter), TRUE);
 is ($model->iter_n_children ($iter), 0);
 
 isa_ok ($iter = $model->iter_nth_child (undef, 7), "Gtk2::TreeIter");
Index: xs/GtkTreeModel.xs
===================================================================
RCS file: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/xs/GtkTreeModel.xs,v
retrieving revision 1.52
diff -u -d -p -r1.52 GtkTreeModel.xs
--- xs/GtkTreeModel.xs 7 Jan 2008 20:23:29 -0000 1.52
+++ xs/GtkTreeModel.xs 4 May 2008 13:11:48 -0000
@@ -313,11 +313,13 @@ static gboolean
 gtk2perl_tree_model_iter_has_child (GtkTreeModel *tree_model,
                                     GtkTreeIter  *iter)
 {
+ SV *sv;
  gboolean ret;
  PREP (tree_model);
  XPUSHs (sv_2mortal (sv_from_iter (iter)));
  CALL ("ITER_HAS_CHILD", G_SCALAR);
- ret = POPi;
+ sv = POPs;
+ ret = sv_2bool (sv);
  FINISH;
  return ret;
 }

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: TreeModel HAS_CHILD return

by Kevin Ryde :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Torsten Schoenfeld <kaffeetisch@...> writes:
>
> Does this work in your case?

Yep.
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: TreeModel HAS_CHILD return

by Torsten Schoenfeld :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kevin Ryde wrote:
>> Does this work in your case?
> Yep.

Committed.

--
Bye,
-Torsten
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: TreeModel HAS_CHILD return

by Kevin Ryde :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Torsten Schoenfeld <kaffeetisch@...> writes:
>
> - ret = POPi;
> + sv = POPs;
> + ret = sv_2bool (sv);

The "pushed_in" return in gtk2perl_menu_position_func() might be similar
too.  Think it's a boolean rather than an integer.


--
If confronted by an angry leopard, John Davis, Keeper of Big Cats
at the Western Plains Zoo, offers this advice:
  * Maintain eye contact.
  * Do not make any sudden movements.
  * Hope the leopard is not hungry.
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: TreeModel HAS_CHILD return

by Torsten Schoenfeld :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kevin Ryde wrote:
>> - ret = POPi;
>> + sv = POPs;
>> + ret = sv_2bool (sv);
>
> The "pushed_in" return in gtk2perl_menu_position_func() might be similar
> too.  Think it's a boolean rather than an integer.

Fixed in HEAD.  Thanks for reporting.

--
Bye,
-Torsten
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
LightInTheBox - Buy quality products at wholesale price