From 837842f1f1607fac8b9caf5bcd3f6b0063cfd118 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 2 May 2021 09:08:30 +0300 Subject: [PATCH] layout:add function to remove orphan subcontainment --- app/layout/genericlayout.cpp | 32 ++++++++++++++++++++++++++++---- app/layout/genericlayout.h | 3 +++ app/layouts/storage.cpp | 20 ++++++++++++++++---- app/layouts/storage.h | 2 ++ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/app/layout/genericlayout.cpp b/app/layout/genericlayout.cpp index da56ee939..108c6dff8 100644 --- a/app/layout/genericlayout.cpp +++ b/app/layout/genericlayout.cpp @@ -1651,12 +1651,36 @@ void GenericLayout::removeView(const Latte::Data::View &viewData) } Plasma::Containment *viewcontainment = containmentForId(viewData.id.toUInt()); + destroyContainment(viewcontainment); +} - if (viewcontainment) { - m_containments.removeAll(viewcontainment); - viewcontainment->setImmutability(Plasma::Types::Mutable); - viewcontainment->destroy(); +void GenericLayout::removeOrphanedSubContainment(const int &containmentId) +{ + Data::ViewsTable views = viewsTable(); + QString cidstr = QString::number(containmentId); + + if (views.hasContainmentId(cidstr)) { + return; } + + if (!isActive()) { + Layouts::Storage::self()->removeContainment(file(), cidstr); + return; + } + + Plasma::Containment *orphanedcontainment = containmentForId(cidstr.toUInt()); + destroyContainment(orphanedcontainment); +} + +void GenericLayout::destroyContainment(Plasma::Containment *containment) +{ + if (!containment) { + return; + } + + m_containments.removeAll(containment); + containment->setImmutability(Plasma::Types::Mutable); + containment->destroy(); } QString GenericLayout::storedView(const int &containmentId) diff --git a/app/layout/genericlayout.h b/app/layout/genericlayout.h index 507b73072..731c415c6 100644 --- a/app/layout/genericlayout.h +++ b/app/layout/genericlayout.h @@ -129,6 +129,7 @@ public: void removeView(const Latte::Data::View &viewData); void updateView(const Latte::Data::View &viewData); QString storedView(const int &containmentId); //returns temp filepath containing all view data + void removeOrphanedSubContainment(const int &containmentId); //! Available edges for specific view in that screen virtual QList availableEdgesForView(QScreen *scr, Latte::View *forView) const; @@ -207,6 +208,8 @@ private: QList sortedViewsData(const QList &viewsData); + void destroyContainment(Plasma::Containment *containment); + private: bool m_blockAutomaticLatteViewCreation{false}; diff --git a/app/layouts/storage.cpp b/app/layouts/storage.cpp index d63571662..a71678d7a 100644 --- a/app/layouts/storage.cpp +++ b/app/layouts/storage.cpp @@ -1582,15 +1582,27 @@ void Storage::removeView(const QString &filepath, const Data::View &viewData) return; } + removeContainment(filepath, viewData.id); + + for (int i=0; i