Package: python-kiwi
Version: 1.9.9-2
Severity: normal

If you type some text into a ComboEntry (so that the completion list
will be shown) and then call its select method with a value that's not
on the shown completion list, it will fail with the following
traceback: 

Traceback (most recent call last):
  File "comboentry_bug_demo.py", line 9, in go
    widget.select(place)
  File "/var/lib/python-support/python2.4/kiwi/ui/comboentry.py", line 573, in 
select
    self.set_active_iter(treeiter)
  File "/var/lib/python-support/python2.4/kiwi/ui/comboentry.py", line 519, in 
set_active_iter
    self._popup.set_selected_iter(iter)
  File "/var/lib/python-support/python2.4/kiwi/ui/comboentry.py", line 325, in 
set_selected_iter
    iter = model.convert_child_iter_to_iter(iter)

To reproduce this, you can run the attached comboentry_bug_demo.py and
follow these steps:

1 - type 'f' into the ComboEntry and select the 'foo' item
2 - click on the "Go to bar" Button

This happens because, even after the selection of the item, the model
for the TreeView continues to be the FilteredModel for the completion
list. I've fixed this (patch attached) by trying the full list model
if this conversion fails.

Regards,

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-3-686
Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to pt_BR.UTF-8)

Versions of packages python-kiwi depends on:
ii  python                        2.4.4-2    An interactive high-level object-o
ii  python-gtk2                   2.8.6-8    Python bindings for the GTK+ widge
ii  python-setuptools             0.6c3-3    Python Distutils Enhancements
ii  python-support                0.5.6      automated rebuilding support for p

python-kiwi recommends no packages.

-- no debconf information
import sys

import gtk

from kiwi.ui.comboentry import ComboEntry

def goto(widget, place):
    def go(*args):
        widget.select(place)
    return go



def main(args):
    w = gtk.Window()
    w.set_position(gtk.WIN_POS_CENTER)
    w.set_size_request(250, -1)
    w.set_title('ComboEntry example')
    w.connect('delete-event', gtk.main_quit)

    e = ComboEntry()
    e.prefill(['foo', 'bar', 'baz', 'biz', 'boz',
               'bsz', 'byz', 'kus', 'kaz', 'kes',
               'buz', 'bwq', 'uys'])
    goto_bar = gtk.Button("Go to bar");
    goto_bar.connect('clicked', goto(e, 'bar'))
    vbox = gtk.VBox()
    vbox.pack_start(e)
    vbox.pack_start(goto_bar)
    w.add(vbox)

    w.show_all()
    gtk.main()

if __name__ == '__main__':
    sys.exit(main(sys.argv))
--- kiwi/ui/comboentry.py~      2006-08-24 21:43:21.000000000 -0300
+++ kiwi/ui/comboentry.py       2007-01-14 22:58:29.000000000 -0200
@@ -322,7 +322,17 @@
         # being used is a TreeModelFiter, convert it to be a TreeModelFiter
         # iter
         if isinstance(model, gtk.TreeModelFilter):
-            iter = model.convert_child_iter_to_iter(iter)
+            try:
+                iter = model.convert_child_iter_to_iter(iter)
+            except Exception, ex:
+                if model.get_model().iter_is_valid(iter):
+                    # revert back to the unfiltered model so we can select
+                    # the right object
+                    self._treeview.set_model(model.get_model())
+                    self._selection = self._treeview.get_selection()
+                else:
+                    raise
+
         self._selection.select_iter(iter)
 
 type_register(_ComboEntryPopup)

Reply via email to