X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Ftreemodel.cpp;h=3e243a42023924d4357bc43b7e47ff0133c89fea;hp=d1cc465dd3fc6dcdf2cd6256424992b83406d6b6;hb=a700bd999215313b075ced5a1e3ba4ea8917fbbc;hpb=cc6e7c08709c4e761e2fd9c2e322751015497003 diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index d1cc465d..3e243a42 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2019 by the Quassel Project * + * Copyright (C) 2005-2020 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 consitency and the child gets deleted anyways child->removeAllChilds(); ++childIter; } @@ -569,9 +568,15 @@ 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.child(i, 0); + child = parent.model()->index(i, 0, parent); Q_ASSERT(parentItem->child(i)); qDebug() << ">>>" << i << child << child.data().toString(); } @@ -585,9 +590,15 @@ 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.child(i, 0); + child = parent.model()->index(i, 0, parent); Q_ASSERT(parentItem->child(i)); qDebug() << "<<<" << i << child << child.data().toString(); }