From 44bbef3e69a071f49fc24f97d7ce34186a5ac257 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Mon, 9 Sep 2024 13:19:50 +0100 Subject: [PATCH] fix: Prevent crash due to current layout being null I can't reproduce any crash but it has been seen in the wild. Doing a code review, I can't find any path for it to be null. The assert and qWarning will be enough to make a test fail eventually. --- src/core/Position.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/Position.cpp b/src/core/Position.cpp index 75acf9225..0457598ec 100644 --- a/src/core/Position.cpp +++ b/src/core/Position.cpp @@ -183,6 +183,11 @@ void Positions::deserialize(const LayoutSaver::Position &lp) continue; // Skip } else { assert(LayoutSaver::Layout::s_currentLayoutBeingRestored); + if (!LayoutSaver::Layout::s_currentLayoutBeingRestored) { + /// Doesn't happen, but let's guard it + KDDW_WARN("Positions::deserialize: Current layout is null, report a bug!"); + continue; + } auto serializedFw = LayoutSaver::Layout::s_currentLayoutBeingRestored->floatingWindowForIndex( index);