PyGobject TreeModel selection bug?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

PyGobject TreeModel selection bug?

Brent S. Elmer Ph.D.
I have an application I wrote using PyGTK that I recently converted
to use PyGobject introspection.  When I try to do something with
selections in a TreeModel, I get a segmentation fault.  The
corresponding pygtk code works.  I have pared down my program to a
simple test case.  I have included the pygtk version that works and the
PyGobject version that gives a segmentation fault.  To see what I mean,
run the programs and select one or multiple rows then select File->copy
from the menu.  Is this a PyGobject bug or am I doing something wrong?

 

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

pygtk_test3.py (4K) Download Attachment
gi_test3.py (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: PyGobject TreeModel selection bug?

Neil Muller-10
On 3 June 2013 20:24, Brent S. Elmer Ph.D. <[hidden email]> wrote:
> I have an application I wrote using PyGTK that I recently converted
> to use PyGobject introspection.  When I try to do something with
> selections in a TreeModel, I get a segmentation fault.  The
> corresponding pygtk code works.  I have pared down my program to a
> simple test case.  I have included the pygtk version that works and the
> PyGobject version that gives a segmentation fault.  To see what I mean,
> run the programs and select one or multiple rows then select File->copy
> from the menu.  Is this a PyGobject bug or am I doing something wrong?

The problem is the selected_foreach loop here. I'm pretty sure the
issue is there's a discrepency between the references created by gtk
and the python object references in this code path, so you end up with
a path that references something gtk has dropped it's references to.

This is probably a PyGobject bug, but I'm not sure of all the details,
so there may be a reason for the current behaviour.

You can avoid the issue by either expliticly copying the path in your
selection_callback function - i.e, using pathlist.append(path.copy()),
or by using the treeselection's get_selected_rows method.

--
Neil Muller
[hidden email]

I've got a gmail account. Why haven't I become cool?
_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: PyGobject TreeModel selection bug?

Brent S. Elmer Ph.D.

> The problem is the selected_foreach loop here. I'm pretty sure the
> issue is there's a discrepency between the references created by gtk
> and the python object references in this code path, so you end up with
> a path that references something gtk has dropped it's references to.
>
> This is probably a PyGobject bug, but I'm not sure of all the details,
> so there may be a reason for the current behaviour.
>
> You can avoid the issue by either expliticly copying the path in your
> selection_callback function - i.e, using pathlist.append(path.copy()),
> or by using the treeselection's get_selected_rows method.
>
Thanks for the help.  Here is my modified code that works.  I used
treeselections's get_selected_rows.

Brent

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

gi_test3.py (5K) Download Attachment