From 1e48d053f7a41d1abb8334e471a52009aedd9805 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 8 May 2020 10:16:26 +0300 Subject: [PATCH] fix crash when switching layouts -- the faulter was containmentinterface that was calling containment()->applets() during view destroying phase --- app/view/containmentinterface.cpp | 10 +++++----- app/view/view.cpp | 5 +++++ app/view/view.h | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/view/containmentinterface.cpp b/app/view/containmentinterface.cpp index 43cb069db..02d836ef4 100644 --- a/app/view/containmentinterface.cpp +++ b/app/view/containmentinterface.cpp @@ -389,7 +389,7 @@ int ContainmentInterface::appletIdForIndex(const int index) void ContainmentInterface::deactivateApplets() { - if (!m_view->containment()) { + if (!m_view->containment() || !m_view->inReadyState()) { return; } @@ -404,12 +404,12 @@ void ContainmentInterface::deactivateApplets() bool ContainmentInterface::appletIsExpandable(const int id) { - if (!m_view->containment()) { + if (!m_view->containment() || !m_view->inReadyState()) { return false; } for (const auto applet : m_view->containment()->applets()) { - if (applet->id() == (uint)id) { + if (applet && applet->id() == (uint)id) { if (m_view->layout() && m_view->layout()->isInternalContainment(applet)) { return true; } @@ -427,7 +427,7 @@ bool ContainmentInterface::appletIsExpandable(const int id) bool ContainmentInterface::appletIsExpandable(PlasmaQuick::AppletQuickItem *appletQuickItem) { - if (!appletQuickItem) { + if (!appletQuickItem || !m_view->inReadyState()) { return false; } @@ -499,7 +499,7 @@ bool ContainmentInterface::appletIsExpanded(const int id) void ContainmentInterface::toggleAppletExpanded(const int id) { - if (!m_view->containment()) { + if (!m_view->containment() || !m_view->inReadyState()) { return; } diff --git a/app/view/view.cpp b/app/view/view.cpp index 7b6db1279..4be662955 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -318,6 +318,11 @@ bool View::inDelete() const return m_inDelete; } +bool View::inReadyState() const +{ + return (m_layout != nullptr); +} + void View::disconnectSensitiveSignals() { m_initLayoutTimer.stop(); diff --git a/app/view/view.h b/app/view/view.h index b0f338352..d71e0259a 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -140,6 +140,7 @@ public: void setAlternativesIsShown(bool show); bool inDelete() const; + bool inReadyState() const; bool onPrimary() const; void setOnPrimary(bool flag);