Fix a crash that may happen during initial loading in certain circumstances

This commit is contained in:
Michael Zanetti 2021-12-18 12:54:59 +01:00
parent a0b76f7d74
commit ce151b3cff
2 changed files with 9 additions and 2 deletions

View File

@ -31,11 +31,14 @@
#ifndef THINGS_H
#define THINGS_H
#include <QAbstractListModel>
#include "types/thing.h"
#include "types/thingclass.h"
#include <QAbstractListModel>
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(dcThingManager)
class Things : public QAbstractListModel
{
Q_OBJECT

View File

@ -583,6 +583,10 @@ bool ThingsProxy::lessThan(const QModelIndex &left, const QModelIndex &right) co
bool ThingsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
Thing *thing = getInternal(source_row);
if (!thing) {
qCWarning(dcThingManager()) << "filterAcceptsRow called for a source row we can't find in the source model!";
return false;
}
if (!m_filterTagId.isEmpty()) {
Tag *tag = m_engine->tagsManager()->tags()->findThingTag(thing->id().toString(), m_filterTagId);
if (!tag) {