GTK 2.16 assertion `GTK_IS_TEXT_LAYOUT (layout)' failed



Hi,
When using GTK 2.16 I now get this error when I remove a text view
from a container and re-add it:

GtkWarning: gtk_text_layout_set_preedit_string: assertion
`GTK_IS_TEXT_LAYOUT (layout)' failed

This assertion is only triggered once (when adding the widget after
the first remove). Subsequent remove and add operations works without
error.
I've attached a pygtk script that can be used to trigger the error.

This error did not occur in the previous GTK (<2.16) releases.

I've tested on Win32 (Windows XP) and GTK bundle
"gtk+-bundle_2.16.0-20090317_win32.zip".

Is this due to mistake in my code or is it a GTK bug?

Regards,
Fredrik
#!/usr/bin/env python
import gtk

msg = '''
In GTK 2.16 the first time you trigger a remove and readd of the this text widget 
by pressing the button the following assertion error is written to stderr:

GtkWarning: gtk_text_layout_set_preedit_string: assertion `GTK_IS_TEXT_LAYOUT (layout)' failed

However after the first remove this no longer happens.
'''
class RemovedTextWidgetAssert(gtk.Window):
    def __init__(self, parent=None):
        # Create the toplevel window
        gtk.Window.__init__(self)
        self.connect('destroy', lambda *w: gtk.main_quit())
        self.set_title(self.__class__.__name__)
        self.set_default_size(450, 450)
        self.set_border_width(0)
        self.vbox = gtk.VBox()
        self.add(self.vbox)
        self.switch_button = gtk.Button('Remove and readd text widget')
        self.switch_button.connect("clicked",self._remove_and_readd)
        self.vbox.pack_start(self.switch_button,False,False)

        self.text_view = gtk.TextView()
        self.text_view.get_buffer().set_text(msg)
        self.vbox.pack_start(self.text_view)
        self.show_all()
        def print_evt(w,*args):
            print args
        self.text_view.connect('unmap-event', print_evt)

    def _remove_and_readd(self,*args):
        self.vbox.remove(self.text_view)
        # first time after a remove this triggers (stderr):
        # GtkWarning: gtk_text_layout_set_preedit_string: assertion `GTK_IS_TEXT_LAYOUT (layout)' failed
        self.vbox.pack_start(self.text_view)


def main():
    RemovedTextWidgetAssert()
    gtk.main()

if __name__ == '__main__':
    main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]