1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

AK: Improve smart pointer ergonomics a bit.

This commit is contained in:
Andreas Kling 2019-04-14 02:36:06 +02:00
parent d5dec1922b
commit 3f6408919f
17 changed files with 49 additions and 31 deletions

View file

@ -11,14 +11,14 @@ GLayout::~GLayout()
void GLayout::notify_adopted(Badge<GWidget>, GWidget& widget)
{
if (m_owner.ptr() == &widget)
if (m_owner == &widget)
return;
m_owner = widget.make_weak_ptr();
}
void GLayout::notify_disowned(Badge<GWidget>, GWidget& widget)
{
ASSERT(m_owner.ptr() == &widget);
ASSERT(m_owner == &widget);
m_owner.clear();
}
@ -43,7 +43,7 @@ void GLayout::add_widget(GWidget& widget)
void GLayout::remove_widget(GWidget& widget)
{
m_entries.remove_first_matching([&] (auto& entry) {
return entry.widget.ptr() == &widget;
return entry.widget == &widget;
});
if (m_owner)
m_owner->notify_layout_changed(Badge<GLayout>());