Re: [pygtk] Segfault on TreeView Empty

2004-07-03 Thread Thomas Mills Hinkle
 Have you tried reproducing it on other Unstable boxes?

I've now reproduced it on another unstable box (powerpc 

 Do you have a minimal (20-line) testcase so others can run 
 and verify if the problem exists?

To reproduce the problem, I tried creating a version of the basictreeview example from 
the tutorial that allowed you to delete the selected rows. Removing the last row 
doesn't crash the program. However, hitting delete once the view is empty does 
segfault on my debian unstable box.

I'm guessing my original app somehow calls this when deleting the last row -- I'll 
check later to make sure. In the mean time, this example (slightly modified from the 
tutorial example) does seem to point to a bug somewhere. 

The culprit is treeview.get_selection().get_selected_rows() called with an empty 
treeview. Running the attached tvsegfault.py (which does nothing more than set up an 
empty treeview and call get_selected_rows) will quickly confirm if the segfault is 
reproducible on other systems.

Tom

(p.s. apologies for messing up threading with this message -- my regular computer is 
temporarily out of commission so I don't have access to the original e-mail to reply 
to).

 
Please contribute to my online collaborative literature at
http://tommyrot.arrr.net/qwiki/
 
#!/usr/bin/env python

# example basictreeview.py

import pygtk
pygtk.require('2.0')
import gtk

class BasicTreeViewExample:

# Close the window and quit
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return gtk.FALSE

def __init__(self):
# Create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

self.window.set_title(Basic TreeView Example)

self.window.set_size_request(200, 200)

self.window.connect(delete_event, self.delete_event)

# create a TreeStore with one string column to use as the model
self.treestore = gtk.TreeStore(str)

# we'll add some data now - 4 rows with 3 child rows each
for parent in range(4):
piter = self.treestore.append(None, ['parent %i' % parent])
for child in range(3):
self.treestore.append(piter, ['child %i of parent %i' %
  (child, parent)])

# create the TreeView using treestore
self.treeview = gtk.TreeView(self.treestore)

# allow multiple selections
self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

# create the TreeViewColumn to display the data
self.tvcolumn = gtk.TreeViewColumn('Column 0')

# add tvcolumn to treeview
self.treeview.append_column(self.tvcolumn)

# create a CellRendererText to render the data
self.cell = gtk.CellRendererText()

# add the cell to the tvcolumn and allow it to expand
self.tvcolumn.pack_start(self.cell, True)

# set the cell text attribute to column 0 - retrieve text
# from that column in treestore
self.tvcolumn.add_attribute(self.cell, 'text', 0)

# make it searchable
self.treeview.set_search_column(0)

# Allow sorting on the column
self.tvcolumn.set_sort_column_id(0)

# Allow drag and drop reordering of rows
self.treeview.set_reorderable(True)

# Create delete button
self.deleteB = gtk.Button(Delete Selected Rows)
self.deleteB.connect('clicked',self.delete_rows)

self.vbox = gtk.VBox()

self.vbox.add(self.treeview)
self.vbox.add(self.deleteB)
self.window.add(self.vbox)

self.window.show_all()

def delete_rows (self, *args):
print 'delete_rows called'
treestore,paths=self.treeview.get_selection().get_selected_rows()
print 'got selected rows...'
paths.reverse()
for path in paths:
print 'removing iter@',path
iter = treestore.get_iter(path)
treestore.remove(iter)

def main():
gtk.main()

if __name__ == __main__:
tvexample = BasicTreeViewExample()
main()
#!/usr/bin/env python

# segfaulting example, quickndirty

import pygtk
pygtk.require('2.0')
import gtk

# create a TreeStore with one string column to use as the model
treestore = gtk.TreeStore(str)
treeview = gtk.TreeView(treestore)
treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
treestore,paths=treeview.get_selection().get_selected_rows()
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Segfault on TreeView Empty

2004-07-03 Thread Gustavo J. A. M. Carneiro
  Thanks.  Fixed in CVS.

A Sáb, 2004-07-03 às 23:36, Thomas Mills Hinkle escreveu:
  Have you tried reproducing it on other Unstable boxes?
 
 I've now reproduced it on another unstable box (powerpc 
 
  Do you have a minimal (20-line) testcase so others can run 
  and verify if the problem exists?
 
 To reproduce the problem, I tried creating a version of the basictreeview example 
 from the tutorial that allowed you to delete the selected rows. Removing the last 
 row doesn't crash the program. However, hitting delete once the view is empty does 
 segfault on my debian unstable box.
 
 I'm guessing my original app somehow calls this when deleting the last row -- I'll 
 check later to make sure. In the mean time, this example (slightly modified from the 
 tutorial example) does seem to point to a bug somewhere. 
 
 The culprit is treeview.get_selection().get_selected_rows() called with an empty 
 treeview. Running the attached tvsegfault.py (which does nothing more than set up an 
 empty treeview and call get_selected_rows) will quickly confirm if the segfault is 
 reproducible on other systems.
 
 Tom
 
 (p.s. apologies for messing up threading with this message -- my regular computer is 
 temporarily out of commission so I don't have access to the original e-mail to reply 
 to).
 
  
 Please contribute to my online collaborative literature at
 http://tommyrot.arrr.net/qwiki/
  
 
 __
 #!/usr/bin/env python
 
 # example basictreeview.py
 
 import pygtk
 pygtk.require('2.0')
 import gtk
 
 class BasicTreeViewExample:
 
 # Close the window and quit
 def delete_event(self, widget, event, data=None):
 gtk.main_quit()
 return gtk.FALSE
 
 def __init__(self):
 # Create a new window
 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
 
 self.window.set_title(Basic TreeView Example)
 
 self.window.set_size_request(200, 200)
 
 self.window.connect(delete_event, self.delete_event)
 
 # create a TreeStore with one string column to use as the model
 self.treestore = gtk.TreeStore(str)
 
 # we'll add some data now - 4 rows with 3 child rows each
 for parent in range(4):
 piter = self.treestore.append(None, ['parent %i' % parent])
 for child in range(3):
 self.treestore.append(piter, ['child %i of parent %i' %
   (child, parent)])
 
 # create the TreeView using treestore
 self.treeview = gtk.TreeView(self.treestore)
 
 # allow multiple selections
 self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
 
 # create the TreeViewColumn to display the data
 self.tvcolumn = gtk.TreeViewColumn('Column 0')
 
 # add tvcolumn to treeview
 self.treeview.append_column(self.tvcolumn)
 
 # create a CellRendererText to render the data
 self.cell = gtk.CellRendererText()
 
 # add the cell to the tvcolumn and allow it to expand
 self.tvcolumn.pack_start(self.cell, True)
 
 # set the cell text attribute to column 0 - retrieve text
 # from that column in treestore
 self.tvcolumn.add_attribute(self.cell, 'text', 0)
 
 # make it searchable
 self.treeview.set_search_column(0)
 
 # Allow sorting on the column
 self.tvcolumn.set_sort_column_id(0)
 
 # Allow drag and drop reordering of rows
 self.treeview.set_reorderable(True)
 
 # Create delete button
 self.deleteB = gtk.Button(Delete Selected Rows)
 self.deleteB.connect('clicked',self.delete_rows)
 
 self.vbox = gtk.VBox()
 
 self.vbox.add(self.treeview)
 self.vbox.add(self.deleteB)
 self.window.add(self.vbox)
 
 self.window.show_all()
 
 def delete_rows (self, *args):
 print 'delete_rows called'
 treestore,paths=self.treeview.get_selection().get_selected_rows()
 print 'got selected rows...'
 paths.reverse()
 for path in paths:
 print 'removing iter@',path
 iter = treestore.get_iter(path)
 treestore.remove(iter)
 
 def main():
 gtk.main()
 
 if __name__ == __main__:
 tvexample = BasicTreeViewExample()
 main()
 
 __
 #!/usr/bin/env python
 
 # segfaulting example, quickndirty
 
 import pygtk
 pygtk.require('2.0')
 import gtk
 
 # create a TreeStore with one string column to use as the model
 treestore = gtk.TreeStore(str)
 treeview = gtk.TreeView(treestore)
 treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
 treestore,paths=treeview.get_selection().get_selected_rows()
 
 __
 ___
 pygtk mailing list   

Re: [pygtk] Segfault on TreeView Empty

2004-07-02 Thread Christian Robottom Reis
On Fri, Jul 02, 2004 at 12:31:53AM -0400, Thomas Mills Hinkle wrote:
 I have a funny feeling that this, like the other segfaults I experienced
 when rearranging treeViews, will not be reproducible on other
 machines -- but if it's standard on a debian unstable system, perhaps
 someone else has run into it.

Have you tried reproducing it on other Unstable boxes?

Do you have a minimal (20-line) testcase so others can run and verify if
the problem exists?

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/