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
=== modified file 'po/unity.pot'
--- po/unity.pot 2010-11-25 16:23:26 +0000
+++ po/unity.pot 2010-11-29 17:22:20 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n"10"Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n"
11"POT-Creation-Date: 2010-11-24 13:32-0500\n"11"POT-Creation-Date: 2010-11-28 20:25-0500\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
1515
=== modified file 'src/QuicklistMenuItem.cpp'
--- src/QuicklistMenuItem.cpp 2010-11-25 13:01:34 +0000
+++ src/QuicklistMenuItem.cpp 2010-11-29 17:22:20 +0000
@@ -237,6 +237,9 @@
237 if (!font)237 if (!font)
238 return;238 return;
239239
240 if (_text == NULL)
241 return;
242
240 surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);243 surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
241 cr = cairo_create (surface);244 cr = cairo_create (surface);
242 cairo_set_font_options (cr, gdk_screen_get_font_options (screen));245 cairo_set_font_options (cr, gdk_screen_get_font_options (screen));
@@ -395,6 +398,9 @@
395 int height,398 int height,
396 nux::Color color)399 nux::Color color)
397{400{
401 if (_text == NULL)
402 return;
403
398 int textWidth = 0;404 int textWidth = 0;
399 int textHeight = 0;405 int textHeight = 0;
400 PangoLayout* layout = NULL;406 PangoLayout* layout = NULL;
401407
=== modified file 'src/QuicklistMenuItemCheckmark.cpp'
--- src/QuicklistMenuItemCheckmark.cpp 2010-11-25 13:01:34 +0000
+++ src/QuicklistMenuItemCheckmark.cpp 2010-11-29 17:22:20 +0000
@@ -142,6 +142,10 @@
142{142{
143 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;143 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;
144144
145 // Check if the texture have been computed. If they haven't, exit the function.
146 if (!_normalTexture[0])
147 return;
148
145 nux::Geometry base = GetGeometry ();149 nux::Geometry base = GetGeometry ();
146150
147 gfxContext.PushClippingRectangle (base);151 gfxContext.PushClippingRectangle (base);
148152
=== modified file 'src/QuicklistMenuItemLabel.cpp'
--- src/QuicklistMenuItemLabel.cpp 2010-11-25 13:01:34 +0000
+++ src/QuicklistMenuItemLabel.cpp 2010-11-29 17:22:20 +0000
@@ -129,6 +129,10 @@
129QuicklistMenuItemLabel::Draw (nux::GraphicsEngine& gfxContext,129QuicklistMenuItemLabel::Draw (nux::GraphicsEngine& gfxContext,
130 bool forceDraw)130 bool forceDraw)
131{131{
132 // Check if the texture have been computed. If they haven't, exit the function.
133 if (_normalTexture[0] == NULL)
134 return;
135
132 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;136 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;
133137
134 nux::Geometry base = GetGeometry ();138 nux::Geometry base = GetGeometry ();
135139
=== modified file 'src/QuicklistMenuItemRadio.cpp'
--- src/QuicklistMenuItemRadio.cpp 2010-11-25 13:01:34 +0000
+++ src/QuicklistMenuItemRadio.cpp 2010-11-29 17:22:20 +0000
@@ -133,6 +133,10 @@
133QuicklistMenuItemRadio::Draw (nux::GraphicsEngine& gfxContext,133QuicklistMenuItemRadio::Draw (nux::GraphicsEngine& gfxContext,
134 bool forceDraw)134 bool forceDraw)
135{135{
136 // Check if the texture have been computed. If they haven't, exit the function.
137 if (_normalTexture[0] == NULL)
138 return;
139
136 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;140 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;
137141
138 nux::Geometry base = GetGeometry ();142 nux::Geometry base = GetGeometry ();
139143
=== modified file 'src/QuicklistMenuItemSeparator.cpp'
--- src/QuicklistMenuItemSeparator.cpp 2010-11-25 12:27:43 +0000
+++ src/QuicklistMenuItemSeparator.cpp 2010-11-29 17:22:20 +0000
@@ -26,7 +26,6 @@
26{26{
27 SetMinimumHeight (3);27 SetMinimumHeight (3);
28 SetBaseSize (64, 3);28 SetBaseSize (64, 3);
29 _normalTexture = NULL;
30 _item_type = MENUITEM_TYPE_SEPARATOR;29 _item_type = MENUITEM_TYPE_SEPARATOR;
31}30}
3231
@@ -39,7 +38,6 @@
39{38{
40 SetMinimumHeight (3);39 SetMinimumHeight (3);
41 SetBaseSize (64, 3);40 SetBaseSize (64, 3);
42 _normalTexture = NULL;
43 _item_type = MENUITEM_TYPE_SEPARATOR;41 _item_type = MENUITEM_TYPE_SEPARATOR;
44}42}
4543
@@ -53,7 +51,7 @@
53 _pre_layout_width = GetBaseWidth ();51 _pre_layout_width = GetBaseWidth ();
54 _pre_layout_height = GetBaseHeight ();52 _pre_layout_height = GetBaseHeight ();
5553
56 if((_normalTexture == 0) )54 if((_normalTexture[0] == 0) )
57 {55 {
58 UpdateTexture ();56 UpdateTexture ();
59 }57 }
@@ -102,6 +100,10 @@
102QuicklistMenuItemSeparator::Draw (nux::GraphicsEngine& gfxContext,100QuicklistMenuItemSeparator::Draw (nux::GraphicsEngine& gfxContext,
103 bool forceDraw)101 bool forceDraw)
104{102{
103 // Check if the texture have been computed. If they haven't, exit the function.
104 if (_normalTexture[0] == 0)
105 return;
106
105 nux::Geometry base = GetGeometry ();107 nux::Geometry base = GetGeometry ();
106108
107 gfxContext.PushClippingRectangle (base);109 gfxContext.PushClippingRectangle (base);
@@ -118,7 +120,7 @@
118 base.y,120 base.y,
119 base.width,121 base.width,
120 base.height,122 base.height,
121 _normalTexture->GetDeviceTexture(),123 _normalTexture[0]->GetDeviceTexture(),
122 texxform,124 texxform,
123 _color);125 _color);
124126
@@ -160,19 +162,19 @@
160162
161 nux::NBitmapData* bitmap = _cairoGraphics->GetBitmap ();163 nux::NBitmapData* bitmap = _cairoGraphics->GetBitmap ();
162164
163 if (_normalTexture)165 if (_normalTexture[0])
164 _normalTexture->UnReference ();166 _normalTexture[0]->UnReference ();
165167
166 _normalTexture = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture ();168 _normalTexture[0] = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture ();
167 _normalTexture->Update (bitmap);169 _normalTexture[0]->Update (bitmap);
168170
169 delete _cairoGraphics;171 delete _cairoGraphics;
170}172}
171173
172int QuicklistMenuItemSeparator::CairoSurfaceWidth ()174int QuicklistMenuItemSeparator::CairoSurfaceWidth ()
173{175{
174 if (_normalTexture)176 if (_normalTexture[0])
175 return _normalTexture->GetWidth ();177 return _normalTexture[0]->GetWidth ();
176 178
177 return 0;179 return 0;
178}180}
179\ No newline at end of file181\ No newline at end of file
180182
=== modified file 'src/QuicklistMenuItemSeparator.h'
--- src/QuicklistMenuItemSeparator.h 2010-11-25 12:27:43 +0000
+++ src/QuicklistMenuItemSeparator.h 2010-11-29 17:22:20 +0000
@@ -51,8 +51,6 @@
51 void DrawContent (nux::GraphicsEngine& gfxContext, bool forceDraw);51 void DrawContent (nux::GraphicsEngine& gfxContext, bool forceDraw);
5252
53 void PostDraw (nux::GraphicsEngine& gfxContext, bool forceDraw);53 void PostDraw (nux::GraphicsEngine& gfxContext, bool forceDraw);
54
55 nux::BaseTexture* _normalTexture;
5654
57 virtual void UpdateTexture ();55 virtual void UpdateTexture ();
58 56