Skip to content
Commit fc5c8694 authored by Martin Pitt's avatar Martin Pitt
Browse files

Fix crash in Gtk.TextIter overrides

With commit 17cd0fb3 Gtk.TextIter.{forward,backward}_search() returns undefined
pointers when the search was unsuccessful. Actually check the "success" return
value; if it is False return None, just like PyGTK used to.

Thanks to Michael Vogt for discovering this and writing the test case!

Test case:

-------------- 8< -----------------
from gi.repository import Gtk

win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
textview = Gtk.TextView()
buffer = textview.get_buffer()
buffer.set_text("hello world")
win.add(textview)

win.show_all()

iter = buffer.get_start_iter()
end = buffer.get_end_iter()
ret = iter.forward_search("foo",
                          Gtk.TextSearchFlags.VISIBLE_ONLY,
			                            end)
print "this is my return value"
print ret
print "now I crash"
print ret[0].get_offset()

Gtk.main()
-------------- 8< -----------------
parent 38cca3c1
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment