X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient%2Ftreemodel.cpp;h=c08737ce33b228edb1e74d07ed90398091b3c354;hb=c8ddabf364eff2400c61cea395aefe69eb8ba1b3;hp=8d6c8824ae8750d6eeb05bf40e5f014a26d8601b;hpb=a95ad2de573027f9bee36db972bcae4195168d0c;p=quassel.git diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index 8d6c8824..c08737ce 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2020 by the Quassel Project * + * Copyright (C) 2005-2022 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -45,7 +45,6 @@ private: AbstractTreeItem::AbstractTreeItem(AbstractTreeItem* parent) : QObject(parent) , _flags(Qt::ItemIsSelectable | Qt::ItemIsEnabled) - , _treeItemFlags(nullptr) {} bool AbstractTreeItem::newChild(AbstractTreeItem* item) @@ -102,7 +101,7 @@ void AbstractTreeItem::removeAllChilds() childIter = _childItems.begin(); while (childIter != _childItems.end()) { child = *childIter; - child->setTreeItemFlags(nullptr); // disable self deletion, as this would only fuck up consitency and the child gets deleted anyways + child->setTreeItemFlags({}); // disable self deletion, as this would only fuck up consistency and the child gets deleted anyways child->removeAllChilds(); ++childIter; } @@ -518,7 +517,7 @@ void TreeModel::beginRemoveChilds(int firstRow, int lastRow) disconnect(parentItem->child(i), nullptr, this, nullptr); } - // consitency checks + // consistency checks QModelIndex parent = indexByItem(parentItem); Q_ASSERT(firstRow <= lastRow); Q_ASSERT(parentItem->childCount() > lastRow); @@ -569,6 +568,12 @@ void TreeModel::debug_rowsAboutToBeRemoved(const QModelIndex& parent, int start, parentItem = rootItem; qDebug() << "debug_rowsAboutToBeRemoved" << parent << parentItem << parent.data().toString() << rowCount(parent) << start << end; + // Make sure model is valid first + if (!parent.model()) { + qDebug() << "Parent model is not valid!" << end; + return; + } + QModelIndex child; for (int i = end; i >= start; i--) { child = parent.model()->index(i, 0, parent); @@ -585,6 +590,12 @@ void TreeModel::debug_rowsInserted(const QModelIndex& parent, int start, int end parentItem = rootItem; qDebug() << "debug_rowsInserted:" << parent << parentItem << parent.data().toString() << rowCount(parent) << start << end; + // Make sure model is valid first + if (!parent.model()) { + qDebug() << "Parent model is not valid!" << end; + return; + } + QModelIndex child; for (int i = start; i <= end; i++) { child = parent.model()->index(i, 0, parent);