From: Christophe CURIS <christophe.cu...@free.fr>

As reported by Charles Philip Chan, WPrefs would get into infinite loop
when the support for Pango is enabled.

The problem is due to long strings that are broken into multiple lines by
WINGs. This is done in an iterative process in the internal function
'fitText'.

In order to avoid the cost of duplicating many times the sub-strings, the
functions involved do not place a NUL at the string-splitting position, but
they rely instead on giving the length of the string as a parameter.

The code that checks the Pango text (to avoid re-submitting the string when
not needed) did not use that length, so it would always keep the original
string that is too long, so the fitText function would always receive the
same result and loop forever trying to find where to split the string.

This patch adds the check on the length, so Pango is given the appropriate
string for its pixel size calculation.

Signed-off-by: Christophe CURIS <christophe.cu...@free.fr>
---
 WINGs/wfont.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/WINGs/wfont.c b/WINGs/wfont.c
index a5cff07..b3d399c 100644
--- a/WINGs/wfont.c
+++ b/WINGs/wfont.c
@@ -295,7 +295,7 @@ int WMWidthOfString(WMFont * font, const char *text, int 
length)
        wassertrv(font != NULL && text != NULL, 0);
 #ifdef USE_PANGO
        previous_text = pango_layout_get_text(font->layout);
-       if ((previous_text == NULL) || (strcmp(text, previous_text) != 0))
+       if ((previous_text == NULL) || (strncmp(text, previous_text, length) != 
0) || previous_text[length] != '\0')
                pango_layout_set_text(font->layout, text, length);
        pango_layout_get_pixel_size(font->layout, &width, NULL);
 
-- 
2.1.1


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to