From f8bf0081d2569ef08f5c5b3ee3b9c182d11e65cf Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 25 Mar 2013 14:18:01 +0100 Subject: [PATCH] Document undefined behavior regarding Qt::ItemNeverHasChildren. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4c044b206ad6dd57f11d791d8a6a6f3f931acf4f Reviewed-by: Thorbjørn Lund Martsum Reviewed-by: Olivier Goffart --- src/corelib/global/qnamespace.qdoc | 3 +++ src/corelib/itemmodels/qabstractitemmodel.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 0d9cacdb1f..b6ce9e03fd 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2504,6 +2504,9 @@ to be explicitly set for instances of QListWidgetItem, QTableWidgetItem, and QTreeWidgetItem. + Note that it is undefined behavior to reimplement QAbstractItemModel::hasChildren + to return true for an index if that index has the Qt::ItemNeverHasChildren flag set. + \sa QAbstractItemModel */ diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 0d67c1f17b..f152dec5e6 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -1679,6 +1679,9 @@ bool QAbstractItemModel::hasIndex(int row, int column, const QModelIndex &parent Use rowCount() on the parent to find out the number of children. + Note that it is undefined behavior to report that a particular index hasChildren + with this method if the same index has the flag Qt::ItemNeverHasChildren set. + \sa parent(), index() */ bool QAbstractItemModel::hasChildren(const QModelIndex &parent) const