Merge lp:~canonical-dx-team/unity/unity.fix-681515 into lp:unity

Proposed by Jay Taoko
Status: Merged
Merged at revision: 639
Proposed branch: lp:~canonical-dx-team/unity/unity.fix-681515
Merge into: lp:unity
Diff against target: 169 lines (+31/-13)
7 files modified
po/unity.pot (+1/-1)
src/QuicklistMenuItem.cpp (+6/-0)
src/QuicklistMenuItemCheckmark.cpp (+4/-0)
src/QuicklistMenuItemLabel.cpp (+4/-0)
src/QuicklistMenuItemRadio.cpp (+4/-0)
src/QuicklistMenuItemSeparator.cpp (+12/-10)
src/QuicklistMenuItemSeparator.h (+0/-2)
To merge this branch: bzr merge lp:~canonical-dx-team/unity/unity.fix-681515
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+42149@code.launchpad.net

Description of the change

fix for bug #681515
Avoid calculating the text size if the text is null.

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good, approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/unity.pot'
2--- po/unity.pot 2010-11-25 16:23:26 +0000
3+++ po/unity.pot 2010-11-29 17:22:20 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: PACKAGE VERSION\n"
7 "Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n"
8-"POT-Creation-Date: 2010-11-24 13:32-0500\n"
9+"POT-Creation-Date: 2010-11-28 20:25-0500\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13
14=== modified file 'src/QuicklistMenuItem.cpp'
15--- src/QuicklistMenuItem.cpp 2010-11-25 13:01:34 +0000
16+++ src/QuicklistMenuItem.cpp 2010-11-29 17:22:20 +0000
17@@ -237,6 +237,9 @@
18 if (!font)
19 return;
20
21+ if (_text == NULL)
22+ return;
23+
24 surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
25 cr = cairo_create (surface);
26 cairo_set_font_options (cr, gdk_screen_get_font_options (screen));
27@@ -395,6 +398,9 @@
28 int height,
29 nux::Color color)
30 {
31+ if (_text == NULL)
32+ return;
33+
34 int textWidth = 0;
35 int textHeight = 0;
36 PangoLayout* layout = NULL;
37
38=== modified file 'src/QuicklistMenuItemCheckmark.cpp'
39--- src/QuicklistMenuItemCheckmark.cpp 2010-11-25 13:01:34 +0000
40+++ src/QuicklistMenuItemCheckmark.cpp 2010-11-29 17:22:20 +0000
41@@ -142,6 +142,10 @@
42 {
43 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;
44
45+ // Check if the texture have been computed. If they haven't, exit the function.
46+ if (!_normalTexture[0])
47+ return;
48+
49 nux::Geometry base = GetGeometry ();
50
51 gfxContext.PushClippingRectangle (base);
52
53=== modified file 'src/QuicklistMenuItemLabel.cpp'
54--- src/QuicklistMenuItemLabel.cpp 2010-11-25 13:01:34 +0000
55+++ src/QuicklistMenuItemLabel.cpp 2010-11-29 17:22:20 +0000
56@@ -129,6 +129,10 @@
57 QuicklistMenuItemLabel::Draw (nux::GraphicsEngine& gfxContext,
58 bool forceDraw)
59 {
60+ // Check if the texture have been computed. If they haven't, exit the function.
61+ if (_normalTexture[0] == NULL)
62+ return;
63+
64 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;
65
66 nux::Geometry base = GetGeometry ();
67
68=== modified file 'src/QuicklistMenuItemRadio.cpp'
69--- src/QuicklistMenuItemRadio.cpp 2010-11-25 13:01:34 +0000
70+++ src/QuicklistMenuItemRadio.cpp 2010-11-29 17:22:20 +0000
71@@ -133,6 +133,10 @@
72 QuicklistMenuItemRadio::Draw (nux::GraphicsEngine& gfxContext,
73 bool forceDraw)
74 {
75+ // Check if the texture have been computed. If they haven't, exit the function.
76+ if (_normalTexture[0] == NULL)
77+ return;
78+
79 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;
80
81 nux::Geometry base = GetGeometry ();
82
83=== modified file 'src/QuicklistMenuItemSeparator.cpp'
84--- src/QuicklistMenuItemSeparator.cpp 2010-11-25 12:27:43 +0000
85+++ src/QuicklistMenuItemSeparator.cpp 2010-11-29 17:22:20 +0000
86@@ -26,7 +26,6 @@
87 {
88 SetMinimumHeight (3);
89 SetBaseSize (64, 3);
90- _normalTexture = NULL;
91 _item_type = MENUITEM_TYPE_SEPARATOR;
92 }
93
94@@ -39,7 +38,6 @@
95 {
96 SetMinimumHeight (3);
97 SetBaseSize (64, 3);
98- _normalTexture = NULL;
99 _item_type = MENUITEM_TYPE_SEPARATOR;
100 }
101
102@@ -53,7 +51,7 @@
103 _pre_layout_width = GetBaseWidth ();
104 _pre_layout_height = GetBaseHeight ();
105
106- if((_normalTexture == 0) )
107+ if((_normalTexture[0] == 0) )
108 {
109 UpdateTexture ();
110 }
111@@ -102,6 +100,10 @@
112 QuicklistMenuItemSeparator::Draw (nux::GraphicsEngine& gfxContext,
113 bool forceDraw)
114 {
115+ // Check if the texture have been computed. If they haven't, exit the function.
116+ if (_normalTexture[0] == 0)
117+ return;
118+
119 nux::Geometry base = GetGeometry ();
120
121 gfxContext.PushClippingRectangle (base);
122@@ -118,7 +120,7 @@
123 base.y,
124 base.width,
125 base.height,
126- _normalTexture->GetDeviceTexture(),
127+ _normalTexture[0]->GetDeviceTexture(),
128 texxform,
129 _color);
130
131@@ -160,19 +162,19 @@
132
133 nux::NBitmapData* bitmap = _cairoGraphics->GetBitmap ();
134
135- if (_normalTexture)
136- _normalTexture->UnReference ();
137+ if (_normalTexture[0])
138+ _normalTexture[0]->UnReference ();
139
140- _normalTexture = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture ();
141- _normalTexture->Update (bitmap);
142+ _normalTexture[0] = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture ();
143+ _normalTexture[0]->Update (bitmap);
144
145 delete _cairoGraphics;
146 }
147
148 int QuicklistMenuItemSeparator::CairoSurfaceWidth ()
149 {
150- if (_normalTexture)
151- return _normalTexture->GetWidth ();
152+ if (_normalTexture[0])
153+ return _normalTexture[0]->GetWidth ();
154
155 return 0;
156 }
157\ No newline at end of file
158
159=== modified file 'src/QuicklistMenuItemSeparator.h'
160--- src/QuicklistMenuItemSeparator.h 2010-11-25 12:27:43 +0000
161+++ src/QuicklistMenuItemSeparator.h 2010-11-29 17:22:20 +0000
162@@ -51,8 +51,6 @@
163 void DrawContent (nux::GraphicsEngine& gfxContext, bool forceDraw);
164
165 void PostDraw (nux::GraphicsEngine& gfxContext, bool forceDraw);
166-
167- nux::BaseTexture* _normalTexture;
168
169 virtual void UpdateTexture ();
170