Skip to content

Commit e039b75

Browse files
committed
fix
1 parent 3bd9462 commit e039b75

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

include/hyprutils/memory/ImplBase.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ namespace Hyprutils {
5656
}
5757

5858
~impl_base() {
59-
destroy();
60-
if (m_control->_weak == 0 && m_control->_ref == 0)
59+
if (m_control->_ref == 0)
60+
destroy();
61+
62+
if (m_control->_weak == 0)
6163
delete m_control;
6264
}
6365

tests/memory/Memory.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,14 @@ static void testHierarchy() {
170170

171171
child.reset();
172172
EXPECT_TRUE(ifaceAWeak);
173+
EXPECT_TRUE(ifaceA);
173174
EXPECT_EQ(ifaceAWeak->m_ifaceAInt, 69);
175+
EXPECT_EQ(ifaceA->m_ifaceAInt, 69);
174176
ifaceA.reset();
175177
EXPECT_TRUE(ifaceAWeak);
176178
EXPECT_EQ(ifaceAWeak->m_ifaceAInt, 69);
179+
EXPECT_TRUE(ifaceB);
180+
EXPECT_EQ(ifaceB->m_ifaceBInt, 2);
177181
ifaceB.reset();
178182
EXPECT_TRUE(!ifaceAWeak);
179183
}

0 commit comments

Comments
 (0)