From f692b5aa745a846cc9df481b13e0d6d38bde43ba Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 24 Dec 2013 17:11:27 +0100 Subject: [PATCH] crash-- --- src/declarativeimports/core/datasource.cpp | 6 ++++++ src/plasma/datacontainer.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/declarativeimports/core/datasource.cpp b/src/declarativeimports/core/datasource.cpp index 8aeb4679e..6b0336299 100644 --- a/src/declarativeimports/core/datasource.cpp +++ b/src/declarativeimports/core/datasource.cpp @@ -151,7 +151,13 @@ void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine void DataSource::modelChanged(const QString &sourceName, QAbstractItemModel *model) { + if (!model) { + m_models->clear(sourceName); + return; + } + m_models->insert(sourceName, QVariant::fromValue(model)); + //FIXME: this will break in the case a second model is set connect(model, &QObject::destroyed, [=]() { m_models->clear(sourceName); }); diff --git a/src/plasma/datacontainer.cpp b/src/plasma/datacontainer.cpp index b017cf1bc..e8463927a 100644 --- a/src/plasma/datacontainer.cpp +++ b/src/plasma/datacontainer.cpp @@ -380,6 +380,12 @@ void DataContainer::timerEvent(QTimerEvent * event) if (!isUsed()) { // DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED! //qDebug() << objectName() << "is unused"; + + //NOTE: Notifying visualization of the model destruction before actual deletion avoids crashes in some edge cases + if (d->model) { + d->model.clear(); + emit modelChanged(objectName(), 0); + } emit becameUnused(objectName()); } d->checkUsageTimer.stop();