Catch ValueError exception in case of 'foregin' gtk.TextTags in the text.

svn: r10627
This commit is contained in:
Zsolt Foldvari 2008-04-23 09:54:30 +00:00
parent d003d5e61b
commit a4e1be7d62

View File

@ -549,6 +549,7 @@ class StyledTextBuffer(gtk.TextBuffer):
for g_tagname, g_ranges in g_tags.items(): for g_tagname, g_ranges in g_tags.items():
style_and_value = g_tagname.split(' ', 1) style_and_value = g_tagname.split(' ', 1)
try:
style = int(style_and_value[0]) style = int(style_and_value[0])
if len(style_and_value) == 1: if len(style_and_value) == 1:
s_value = None s_value = None
@ -560,6 +561,8 @@ class StyledTextBuffer(gtk.TextBuffer):
s_tag = StyledTextTag(style, s_value, s_ranges) s_tag = StyledTextTag(style, s_value, s_ranges)
s_tags.append(s_tag) s_tags.append(s_tag)
except ValueError:
_LOG.debug("silently skipping gtk.TextTag '%s'" % g_tagname)
return StyledText(txt, s_tags) return StyledText(txt, s_tags)