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
=== modified file 'tests/test_unity_window_view.cpp'
--- tests/test_unity_window_view.cpp 2016-03-31 02:03:55 +0000
+++ tests/test_unity_window_view.cpp 2016-07-21 10:50:16 +0000
@@ -82,12 +82,18 @@
82 view.closable = true;82 view.closable = true;
83 ASSERT_NE(view.close_button_, nullptr);83 ASSERT_NE(view.close_button_, nullptr);
8484
85 auto weak_ptr = nux::ObjectWeakPtr<IconTexture>(view.close_button_);
86 ASSERT_TRUE(weak_ptr.IsValid());
87
85 EXPECT_EQ(view.close_button_->texture(), view.style()->GetTexture(view.scale, WindowTextureType::CLOSE_ICON));88 EXPECT_EQ(view.close_button_->texture(), view.style()->GetTexture(view.scale, WindowTextureType::CLOSE_ICON));
86 EXPECT_EQ(view.close_button_->GetParentObject(), &view);89 EXPECT_EQ(view.close_button_->GetParentObject(), &view);
8790
88 int padding = view.style()->GetCloseButtonPadding().CP(view.scale);91 int padding = view.style()->GetCloseButtonPadding().CP(view.scale);
89 EXPECT_EQ(view.close_button_->GetBaseX(), padding);92 EXPECT_EQ(view.close_button_->GetBaseX(), padding);
90 EXPECT_EQ(view.close_button_->GetBaseY(), padding);93 EXPECT_EQ(view.close_button_->GetBaseY(), padding);
94
95 view.closable = false;
96 ASSERT_FALSE(weak_ptr.IsValid());
91}97}
9298
93TEST_F(TestUnityWindowView, CloseButtonStates)99TEST_F(TestUnityWindowView, CloseButtonStates)
94100
=== modified file 'unity-shared/UnityWindowView.cpp'
--- unity-shared/UnityWindowView.cpp 2016-07-01 17:58:24 +0000
+++ unity-shared/UnityWindowView.cpp 2016-07-21 10:50:16 +0000
@@ -145,6 +145,7 @@
145{145{
146 if (!closable)146 if (!closable)
147 {147 {
148 close_button_->UnParentObject();
148 close_button_ = nullptr;149 close_button_ = nullptr;
149 return;150 return;
150 }151 }