Merge lp:~brandontschaefer/unity/lp.1239381-workaround-7.1 into lp:unity/7.1

Proposed by Brandon Schaefer
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
Merged at revision: 3577
Proposed branch: lp:~brandontschaefer/unity/lp.1239381-workaround-7.1
Merge into: lp:unity/7.1
Diff against target: 78 lines (+54/-1)
1 file modified
dash/ResultRendererTile.cpp (+54/-1)
To merge this branch: bzr merge lp:~brandontschaefer/unity/lp.1239381-workaround-7.1
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Christopher Townsend Approve
Review via email: mp+200691@code.launchpad.net

Commit message

Replaces blacklisted characters with '?'. This is a workaround for an issue else where in pango.

Description of the change

*THIS IS A WORKAROUND*

It causes a crash on characters when renderering. So the workaround for now is to replace all blacklisted characters with '?' until this bug is fixed. As we don't want to crash or filter out results.

To post a comment you must log in.
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok, this is better. +1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/ResultRendererTile.cpp'
2--- dash/ResultRendererTile.cpp 2013-04-30 16:58:48 +0000
3+++ dash/ResultRendererTile.cpp 2014-01-07 16:56:48 +0000
4@@ -45,6 +45,7 @@
5 namespace
6 {
7 const int FONT_SIZE = 10;
8+const char REPLACEMENT_CHAR = '?';
9
10 const float CORNER_HIGHTLIGHT_RADIUS = 2.0f;
11
12@@ -393,6 +394,55 @@
13 }
14 }
15
16+/* Blacklisted unicode ranges:
17+ * Burmese: U+1000 -> U+109F
18+ * Extended: U+AA60 -> U+AA7B
19+*/
20+bool IsBlacklistedChar(gunichar uni_c)
21+{
22+ if ((uni_c >= 0x1000 && uni_c <= 0x109F) ||
23+ (uni_c >= 0xAA60 && uni_c >= 0xAA7B))
24+ {
25+ return true;
26+ }
27+
28+ return false;
29+}
30+
31+// FIXME Bug (lp.1239381) in the backend of pango that crashes
32+// when using ellipsize with/height setting in pango
33+std::string ReplaceBlacklistedChars(std::string const& str)
34+{
35+ std::string new_string("");
36+
37+ if (!g_utf8_validate(str.c_str(), -1, NULL))
38+ return new_string;
39+
40+ gchar const* uni_s = str.c_str();
41+ gunichar uni_c;
42+ gchar utf8_buff[6];
43+
44+ int size = g_utf8_strlen(uni_s, -1);
45+ for (int i = 0; i < size; ++i)
46+ {
47+ uni_s = g_utf8_next_char(uni_s);
48+ uni_c = g_utf8_get_char(uni_s);
49+
50+ if (IsBlacklistedChar(uni_c))
51+ {
52+ new_string += REPLACEMENT_CHAR;
53+ }
54+ else
55+ {
56+ int end = g_unichar_to_utf8(uni_c, utf8_buff);
57+ utf8_buff[end] = '\0';
58+
59+ new_string += utf8_buff;
60+ }
61+ }
62+
63+ return new_string;
64+}
65
66 void ResultRendererTile::LoadText(Result const& row)
67 {
68@@ -426,7 +476,10 @@
69 pango_layout_set_width(layout, (style.GetTileWidth() - (padding * 2))* PANGO_SCALE);
70 pango_layout_set_height(layout, -2);
71
72- char *escaped_text = g_markup_escape_text(row.name().c_str() , -1);
73+ // FIXME bug #1239381
74+ std::string name = ReplaceBlacklistedChars(row.name());
75+
76+ char *escaped_text = g_markup_escape_text(name.c_str(), -1);
77
78 pango_layout_set_markup(layout, escaped_text, -1);
79

Subscribers

People subscribed via source and target branches

to all changes: