Merge lp:~azzar1/unity/fix-crash-close-button-1605010 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 4156
Proposed branch: lp:~azzar1/unity/fix-crash-close-button-1605010
Merge into: lp:unity
Diff against target: 34 lines (+7/-0)
2 files modified
tests/test_unity_window_view.cpp (+6/-0)
unity-shared/UnityWindowView.cpp (+1/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-crash-close-button-1605010
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+300742@code.launchpad.net

Commit message

Properly destroy close_button_ to properly disconnect lambda.

Description of the change

Test case added to make sure the close_button is properly destroyed.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I did the same :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_unity_window_view.cpp'
2--- tests/test_unity_window_view.cpp 2016-03-31 02:03:55 +0000
3+++ tests/test_unity_window_view.cpp 2016-07-21 10:50:16 +0000
4@@ -82,12 +82,18 @@
5 view.closable = true;
6 ASSERT_NE(view.close_button_, nullptr);
7
8+ auto weak_ptr = nux::ObjectWeakPtr<IconTexture>(view.close_button_);
9+ ASSERT_TRUE(weak_ptr.IsValid());
10+
11 EXPECT_EQ(view.close_button_->texture(), view.style()->GetTexture(view.scale, WindowTextureType::CLOSE_ICON));
12 EXPECT_EQ(view.close_button_->GetParentObject(), &view);
13
14 int padding = view.style()->GetCloseButtonPadding().CP(view.scale);
15 EXPECT_EQ(view.close_button_->GetBaseX(), padding);
16 EXPECT_EQ(view.close_button_->GetBaseY(), padding);
17+
18+ view.closable = false;
19+ ASSERT_FALSE(weak_ptr.IsValid());
20 }
21
22 TEST_F(TestUnityWindowView, CloseButtonStates)
23
24=== modified file 'unity-shared/UnityWindowView.cpp'
25--- unity-shared/UnityWindowView.cpp 2016-07-01 17:58:24 +0000
26+++ unity-shared/UnityWindowView.cpp 2016-07-21 10:50:16 +0000
27@@ -145,6 +145,7 @@
28 {
29 if (!closable)
30 {
31+ close_button_->UnParentObject();
32 close_button_ = nullptr;
33 return;
34 }