From 2799a66acba9407a35815933c3b1f2d54f11a0f6 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Mon, 29 Aug 2011 10:28:41 -0700 Subject: [PATCH] Bug fix: Don't infinite loop on notifications with too many characters without a space --- toast.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/toast.py b/toast.py index d7cb8a5..4042b42 100644 --- a/toast.py +++ b/toast.py @@ -182,7 +182,7 @@ class PesterToast(QtGui.QWidget, DefaultToast): if ostools.isWin32(): self.setWindowFlags(QtCore.Qt.ToolTip) else: - self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint| QtCore.Qt.ToolTip) + self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.ToolTip) self.m_animation = QtCore.QParallelAnimationGroup() anim = QtCore.QPropertyAnimation(self) @@ -345,6 +345,14 @@ class PesterToast(QtGui.QWidget, DefaultToast): while metric.width(text, curspace) < maxwidth: lastspace = curspace curspace = text.find(" ", lastspace+1) + if curspace == -1: + break + if (metric.width(text[:lastspace]) > maxwidth) or \ + len(text[:lastspace]) < 1: + for i in xrange(len(text)): + if metric.width(text[:i]) > maxwidth: + lastspace = i-1 + break ret.append(text[:lastspace]) text = text[lastspace+1:] ret.append(text)