This commit is contained in:
Marco Martin 2013-12-24 17:11:27 +01:00
parent 3184551ddb
commit f692b5aa74
2 changed files with 12 additions and 0 deletions

View File

@ -151,7 +151,13 @@ void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine
void DataSource::modelChanged(const QString &sourceName, QAbstractItemModel *model) void DataSource::modelChanged(const QString &sourceName, QAbstractItemModel *model)
{ {
if (!model) {
m_models->clear(sourceName);
return;
}
m_models->insert(sourceName, QVariant::fromValue(model)); m_models->insert(sourceName, QVariant::fromValue(model));
//FIXME: this will break in the case a second model is set
connect(model, &QObject::destroyed, [=]() { connect(model, &QObject::destroyed, [=]() {
m_models->clear(sourceName); m_models->clear(sourceName);
}); });

View File

@ -380,6 +380,12 @@ void DataContainer::timerEvent(QTimerEvent * event)
if (!isUsed()) { if (!isUsed()) {
// DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED! // DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED!
//qDebug() << objectName() << "is unused"; //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()); emit becameUnused(objectName());
} }
d->checkUsageTimer.stop(); d->checkUsageTimer.stop();