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

Proposed by Brandon Schaefer
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3573
Proposed branch: lp:~brandontschaefer/unity/lp.1239381-workaround
Merge into: lp:unity
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
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Stephen M. Webb (community) Approve
Review via email: mp+191320@code.launchpad.net

Commit message

Workaround for now, replace all blacklisted chars in the results name with a '?'. So we can still render all the results with out a crash. This needs to be fixed in pango/harfbuzz.

Description of the change

*THIS IS A WORKAROUND*

The overall problem looks like is in pango/harfbuzz when we set these:

pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_START);
pango_layout_set_width(layout, (style.GetTileWidth() - (padding * 2))* PANGO_SCALE);
pango_layout_set_height(layout, -2);

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
Stephen M. Webb (bregma) wrote :

Seems right.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

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

FAILED: Autolanding.
Approved revid is not set in launchpad. This is most likely a launchpad issue and re-approve should fix it. There is also a chance (although a very small one) this is a permission problem of the ps-jenkins bot.
http://jenkins.qa.ubuntu.com/job/unity-autolanding/358/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-saucy-amd64-autolanding/314
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-saucy-armhf-autolanding/314
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-saucy-i386-autolanding/314

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
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 2013-10-16 02:40:27 +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