ViewGuard: Fix clear() not disconnecting

When clear is called we should disconnect the signal, as it won't
be needed anymore. Benign though.
This commit is contained in:
Sergio Martins
2022-04-05 20:16:50 +01:00
parent 2763aec6c2
commit 4b62714ef5

View File

@@ -42,6 +42,8 @@ View *ViewGuard::operator->()
void ViewGuard::clear()
{
v = nullptr;
if (m_onDestroy.isActive())
m_onDestroy.disconnect();
}
View *ViewGuard::view() const
@@ -51,14 +53,11 @@ View *ViewGuard::view() const
ViewGuard &ViewGuard::operator=(View *view)
{
if (view == v) {
if (view == v)
return *this;
}
// Remove the previous connection
if (m_onDestroy.isActive())
m_onDestroy.disconnect();
clear();
v = view;
m_onDestroy = v->beingDestroyed.connect([this] {