From d0440dd8203a7bcb52a8d4e2e16c53efa5fa60da Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 1 Mar 2016 15:41:41 +0000 Subject: [PATCH] ShellCorona is responsible for the memory management of views Views shouldn't decide to delete themselves. ShellCorona is responsible for managing them, it should be the one managing them in all cases. bring panelContainmentDestroyed and desktopContainmentDestroyed in line REVIEW: 127225 --- shell/panelview.cpp | 1 - shell/shellcorona.cpp | 7 ++++--- shell/shellcorona.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shell/panelview.cpp b/shell/panelview.cpp index 66a1c24d1..c8c3c714c 100644 --- a/shell/panelview.cpp +++ b/shell/panelview.cpp @@ -1029,7 +1029,6 @@ void PanelView::containmentChanged() } views.sync(); } - deleteLater(); } }, Qt::QueuedConnection); } diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index ea3768a8e..667bb8dc5 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -1031,15 +1031,16 @@ void ShellCorona::createWaitingPanels() panel->show(); cont->reactToScreenChange(); - connect(cont, SIGNAL(destroyed(QObject*)), this, SLOT(containmentDeleted(QObject*))); + connect(cont, &QObject::destroyed, this, &ShellCorona::panelContainmentDestroyed); } m_waitingPanels = stillWaitingPanels; emit availableScreenRectChanged(); } -void ShellCorona::containmentDeleted(QObject *cont) +void ShellCorona::panelContainmentDestroyed(QObject *cont) { - m_panelViews.remove(static_cast(cont)); + auto view = m_panelViews.take(static_cast(cont)); + view->deleteLater(); emit availableScreenRectChanged(); } diff --git a/shell/shellcorona.h b/shell/shellcorona.h index b04b10236..b803239eb 100644 --- a/shell/shellcorona.h +++ b/shell/shellcorona.h @@ -180,7 +180,6 @@ private Q_SLOTS: void checkAddPanelAction(const QStringList &sycocaChanges = QStringList()); void addPanel(); void addPanel(QAction *action); - void containmentDeleted(QObject* cont); void populateAddPanelsMenu(); void outputEnabledChanged(); @@ -190,6 +189,7 @@ private Q_SLOTS: void activityOpened(); void activityClosed(); void activityRemoved(); + void panelContainmentDestroyed(QObject* cont); void desktopContainmentDestroyed(QObject*); void showOpenGLNotCompatibleWarning(); void alternativesVisibilityChanged(bool visible);