[pygtk] Segfault when resizing TreeViewColumn

Jon Ellis jon.ellis at libertydistribution.com
Fri Aug 27 01:05:13 WST 2004


I am having trouble with gtk segfaulting when I resize a TreeViewColumn 
under certain conditions.  Attached is a sample demonstrating this 
behavior.

If you launch the sample, and try to resize the TreeViewColumns when 
nothing in the TreeView is selected, it segfaluts.  However, if you 
first select something from the TreeView, and then resize the column, 
everything works perfectly.  I know that something in _onCursorChanged 
is causing this, but I can't quite figure out why.  If you remove 
time.sleep from _onCursorChanged, everything works fine.  Or you can 
remove the while loop, and everything will work also.  For some reason 
when I have a process that takes a good second or so, and then try to 
call gtk.main_iteration(), it segfaults.

I have tested this on pyGTK 2.3.92 as well as 2.0.0.  Any help would be 
greatly appreciated!

--
Jon Ellis <jon.ellis at libertydistribution.com>
-------------- next part --------------
import gtk, gobject
import time
def _onWindowDestroy(*args):
    gtk.main_quit()

def _onCursorChanged(tree):
    time.sleep(1)
    while gtk.events_pending():
        gtk.main_iteration()

def BuildGUI():
    window = gtk.Window()
    window.connect('destroy', _onWindowDestroy)
    window.set_default_size(400,300)

    tree = gtk.TreeView()
    model = gtk.TreeStore(gobject.TYPE_STRING,
                          gobject.TYPE_STRING)
    
    tree.set_model(model)
    tree.connect('cursor-changed', _onCursorChanged)
    
    column = gtk.TreeViewColumn('Column1', gtk.CellRendererText(), markup=0)
    column.set_resizable(True)
    tree.append_column(column)

    tree.set_model(model)
    column = gtk.TreeViewColumn('Column2', gtk.CellRendererText(), markup=1)
    column.set_resizable(True)
    tree.append_column(column)

    window.add(tree)
    tree.show()

    window.show()
    iter = model.append(None)
    model.set(iter,
              0, 'Test1',
              1, 'Test2')



BuildGUI()
gtk.main()


More information about the pygtk mailing list