From 2ff040a7440ec4758694e1e9f469fff5b90f9f61 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 17 May 2023 11:04:58 +0300 Subject: [PATCH] plugins/slidingpopups: Fix a crash on compositing restart The sliding popups effect can be unloaded while there's still an active animation for a closed window. If that happens, the EffectsHandler::windowDeleted signal may be emitted when the EffectWindowDeletedRef objects are destroyed. It happens after the SlidingPopupsEffect destructor. The sliding popups effect also has an EffectsHandler::windowDeleted slot. So, the problem is that m_animationsData gets destroyed first, then m_animations is destroyed next. When m_animations is destroyed, the deleted references will be released and EffectsHandler::windowDeleted will be emitted. SlidingPopupsEffect::slotWindowDeleted will access m_animationsData whose memory has been just released. In order to prevent crashing, this change ensures that animations are canceled while m_animationsData is still valid. --- src/plugins/slidingpopups/slidingpopups.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/slidingpopups/slidingpopups.cpp b/src/plugins/slidingpopups/slidingpopups.cpp index 295c51e211..5f850ecbf5 100644 --- a/src/plugins/slidingpopups/slidingpopups.cpp +++ b/src/plugins/slidingpopups/slidingpopups.cpp @@ -82,6 +82,11 @@ SlidingPopupsEffect::~SlidingPopupsEffect() if (s_slideManager) { s_slideManagerRemoveTimer->start(1000); } + + // Cancel animations here while both m_animations and m_animationsData are still valid. + // slotWindowDeleted may access m_animationsData when an animation is removed. + m_animations.clear(); + m_animationsData.clear(); } bool SlidingPopupsEffect::supported()