diff --git a/src/Platform.cpp b/src/Platform.cpp index c874cd20..5172d690 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -118,6 +118,7 @@ void Platform::tests_initPlatform(int &argc, char **argv, KDDockWidgets::Fronten void Platform::tests_deinitPlatform() { auto plat = Platform::instance(); + plat->d->m_inDestruction = true; plat->tests_deinitPlatform_impl(); delete plat; diff --git a/src/private/Platform_p.h b/src/private/Platform_p.h index 730d84b2..6109ca17 100644 --- a/src/private/Platform_p.h +++ b/src/private/Platform_p.h @@ -28,5 +28,12 @@ public: /// to window activations and use a different style depending on activation state. KDBindings::Signal> windowActivated; KDBindings::Signal> windowDeactivated; + + bool inDestruction() const + { + return m_inDestruction; + } + + bool m_inDestruction = false; }; } diff --git a/src/private/multisplitter/Item.cpp b/src/private/multisplitter/Item.cpp index b258df47..bf37c848 100644 --- a/src/private/multisplitter/Item.cpp +++ b/src/private/multisplitter/Item.cpp @@ -18,7 +18,8 @@ #include "kdbindings/signal.h" #include "Window.h" #include "../View_p.h" - +#include "Platform.h" +#include "../Platform_p.h" #include #include @@ -1002,6 +1003,13 @@ bool ItemBoxContainer::checkSanity() { d->m_checkSanityScheduled = false; + auto plat = Platform::instance(); + if (!plat || plat->d->inDestruction()) { + // checkSanity() can be called with deleteLater(), so check if we still + // have a platform + return true; + } + if (!hostView()) { /// This is a dummy ItemBoxContainer, just return true return true;