Merge lp:~mandel/unity/fix-static-cairo-text into lp:unity

Proposed by Manuel de la Peña
Status: Superseded
Proposed branch: lp:~mandel/unity/fix-static-cairo-text
Merge into: lp:unity
Diff against target: 89 lines (+46/-12)
2 files modified
tests/test_static_cairo_text.cpp (+31/-6)
unity-shared/StaticCairoText.cpp (+15/-6)
To merge this branch: bzr merge lp:~mandel/unity/fix-static-cairo-text
Reviewer Review Type Date Requested Status
Tim Penhey (community) Needs Fixing
Brandon Schaefer (community) Needs Fixing
Marco Trevisan (Treviño) Approve
Nick Dedekind (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+138141@code.launchpad.net

This proposal has been superseded by a proposal from 2012-12-10.

Commit message

- Fixes #1071327 by ensuring that the PreLayoutManagement method does not call SetBaseSize unless is really needed else (if it is called) the method will be called again making the nux layout get into an infinite loop.

Description of the change

Fixes #1071327 by ensuring that the PreLayoutManagement method does not call SetBaseSize unless is really needed else (if it is called) the method will be called again making the nux layout get into an infinite loop.

Tests can be ran doing ./tests/test-gtest --gtest_filter=*TestStaticCairoText* from the build dir.

To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

LGTM.
Tests provided succeed.

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Waiting for a proper fix in nux, this is fine.

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

This causes a regression in the tooltips...

http://i.imgur.com/cVZUb.jpg

review: Needs Fixing
Revision history for this message
Tim Penhey (thumper) wrote :
Revision history for this message
Tim Penhey (thumper) wrote :

A test should be added to work out why tooltip rendering broke, and make the tests pass.

review: Needs Fixing
Revision history for this message
Manuel de la Peña (mandel) wrote :

Sorry, I did not check that the launcher would work correctly and I just focused on the Dash. Is a very simple fix will push asap (The min height of the label has to be the one returned by extend).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_static_cairo_text.cpp'
2--- tests/test_static_cairo_text.cpp 2012-11-30 09:56:52 +0000
3+++ tests/test_static_cairo_text.cpp 2012-12-07 16:24:25 +0000
4@@ -33,17 +33,29 @@
5 class MockStaticCairoText : public nux::StaticCairoText
6 {
7 public:
8+ MOCK_METHOD2(SetBaseSize, void(int, int));
9+
10 MockStaticCairoText():StaticCairoText("") {}
11
12 using StaticCairoText::GetTextureStartIndices;
13 using StaticCairoText::GetTextureEndIndices;
14-};
15-
16-TEST(TestStaticCairoText, TextTextureSize)
17-{
18+ using StaticCairoText::PreLayoutManagement;
19+};
20+
21+class TestStaticCairoText : public ::testing::Test
22+{
23+ protected:
24+ TestStaticCairoText() : Test()
25+ {
26+ text = new MockStaticCairoText();
27+ }
28+ nux::ObjectPtr<MockStaticCairoText> text;
29+};
30+
31+TEST_F(TestStaticCairoText, TextTextureSize)
32+{
33+ EXPECT_CALL(*text.GetPointer(), SetBaseSize(_, _)).Times(AnyNumber());
34 // Test multi-texture stitching support.
35-
36- nux::ObjectPtr<MockStaticCairoText> text(new MockStaticCairoText());
37 text->SetLines(-2000);
38 text->SetMaximumWidth(100);
39
40@@ -70,4 +82,17 @@
41 }
42 }
43
44+TEST_F(TestStaticCairoText, TextPreLayoutManagementMultipleCalls)
45+{
46+ EXPECT_CALL(*text.GetPointer(), SetBaseSize(_, _)).Times(2);
47+
48+ text->PreLayoutManagement();
49+
50+ // the first prelayout methods should have called set base size and therefore
51+ // we should not call it again
52+ EXPECT_CALL(*text.GetPointer(), SetBaseSize(_, _)).Times(0);
53+
54+ text->PreLayoutManagement();
55+}
56+
57 }
58
59=== modified file 'unity-shared/StaticCairoText.cpp'
60--- unity-shared/StaticCairoText.cpp 2012-12-04 11:30:14 +0000
61+++ unity-shared/StaticCairoText.cpp 2012-12-07 16:24:25 +0000
62@@ -228,12 +228,21 @@
63
64 void StaticCairoText::PreLayoutManagement()
65 {
66- Geometry geo = GetGeometry();
67- pimpl->pre_layout_size_.width = geo.width;
68- pimpl->pre_layout_size_.height = geo.height;
69-
70- SetBaseSize(pimpl->cached_extent_.width,
71- pimpl->cached_extent_.height);
72+ Geometry const& geo = GetGeometry();
73+
74+ // only update the size if an only if and only if the width and height of
75+ // the geo are diff
76+ // FIXME: nux should be smart enough to not need this, we should get that
77+ // fixed.
78+ if(pimpl->pre_layout_size_.width != geo.width
79+ || pimpl->pre_layout_size_.height != geo.height)
80+ {
81+ pimpl->pre_layout_size_.width = geo.width;
82+ pimpl->pre_layout_size_.height = geo.height;
83+
84+ SetBaseSize(pimpl->cached_extent_.width,
85+ pimpl->cached_extent_.height);
86+ }
87
88 if (pimpl->textures2D_.empty())
89 {