Gtk UI: Fix crash on OS X when truncating tooltip (bug 1825)

When displaying a long episode description in a tooltip in the
"New episodes available" dialog, gPodder cuts it at a certain
number of characters. However, Russian descriptions are regular,
non-unicode python strings, and gPodder may cut only a part of a
multi-byte UTF-8 sequence. Displaying such a string crashes
gPodder on OS X.

This patch fixes that by converting the description to a unicode
string if it's not unicode.
This commit is contained in:
Eugene Nikolsky 2013-05-12 23:40:50 +03:00
parent 429ab2772b
commit e1ce9b0551

View file

@ -260,6 +260,9 @@ class gPodderEpisodeSelector(BuilderWidget):
self.last_tooltip_episode = index
description = util.remove_html_tags(description)
# Bug 1825: make sure description is a unicode string,
# so it may be cut correctly on UTF-8 char boundaries
description = util.convert_bytes(description)
if description is not None:
if len(description) > 400:
description = description[:398]+'[...]'