Fix potential crash found by the tests
Item::checkSanity() can be called via deleteLater when we don't have a platform anymore
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -28,5 +28,12 @@ public:
|
||||
/// to window activations and use a different style depending on activation state.
|
||||
KDBindings::Signal<std::shared_ptr<View>> windowActivated;
|
||||
KDBindings::Signal<std::shared_ptr<View>> windowDeactivated;
|
||||
|
||||
bool inDestruction() const
|
||||
{
|
||||
return m_inDestruction;
|
||||
}
|
||||
|
||||
bool m_inDestruction = false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#include "kdbindings/signal.h"
|
||||
#include "Window.h"
|
||||
#include "../View_p.h"
|
||||
|
||||
#include "Platform.h"
|
||||
#include "../Platform_p.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QDebug>
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user