PyGTK TreeView segmentation fault on expand_all()

Discussion in 'Python' started by Chris Johnson, Aug 7, 2006.

  1. Good morning.

    I have recently begun a project using PyGTK, and part of my planned
    interface has a gtk.TreeView showing a portion of the filesystem. Now,
    rather than load the entire FS structure into the tree right from the
    beginning, I made a lazy tree by adding blank children to rows
    representing directories, and connected a call to fill in the data when
    a row with blank children was expanded.

    Now, this works all fine and well, in general. I can browse my entire
    filesystem this way. But I noticed that hitting '*' (which I believe is
    a call to expand_all(), though the documentation does not say this
    explicitly) on a row representing any empty directory causes a
    segmentation fault.

    This problem can be alleviated by not removing the blank child after
    attempting to add directory contents, but I would like to avoid this
    approach.

    My suspicion is that expand_all() assumes that there are children
    present, and when I remove the blank row (after attempting to add any
    subdirectories and files), it does not check to make sure there are
    still children.

    So I suppose I have a couple questions. First, can anybody confirm my
    suspicions? Secondly, is this a PyGTK bug, or am I doing something that
    simply should never be done? Finally, do you see any way to fix this
    problem?

    Code follows
    ----------
    def onExpand(self, view, iter, path):
    """Add directory contents on first expansion of its entry"""
    sorted = view.get_model() # TreeModelSort
    iter = sorted.convert_iter_to_child_iter(None,iter)
    store = sorted.get_model() # TreeStore
    child = store.iter_children(iter)
    cpath = store.get(iter,1)[0][1:] # Hidden column with fs path
    info
    if store.get_value(child, 0) is None:
    sorted.addDir(cpath,iter)
    store.remove(child)

    ---------

    If any other code is necessary, I can provide my entire program.
    However, I think I've isolated the problem to that last line (execution
    continues beyond it, so it's not exactly the line itself), and want to
    hear any recommendations for how to still remove that blank child
    without causing expand_all() to fall on its face.
     
    Chris Johnson, Aug 7, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andre Lerche

    treeview / pygtk problem

    Andre Lerche, Jul 10, 2003, in forum: Python
    Replies:
    3
    Views:
    469
    David M. Cook
    Jul 11, 2003
  2. Franck Pommereau

    [PyGTK] forbid focus of TreeView columns

    Franck Pommereau, Feb 21, 2005, in forum: Python
    Replies:
    0
    Views:
    484
    Franck Pommereau
    Feb 21, 2005
  3. manatlan
    Replies:
    0
    Views:
    449
    manatlan
    Apr 25, 2005
  4. Fabian Braennstroem

    change keybindings for pygtk treeview

    Fabian Braennstroem, Oct 27, 2006, in forum: Python
    Replies:
    0
    Views:
    317
    Fabian Braennstroem
    Oct 27, 2006
  5. cypher543
    Replies:
    2
    Views:
    347
    Hendrik van Rooyen
    Dec 29, 2006
Loading...

Share This Page