From 57e9d9e38e7cb52011438133dd7cdd749a410d00 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 2 Dec 2020 15:40:14 +0100 Subject: Dont' return a const ref to QModelIndex The conversion operator from QPMI to QModelIndex should return by value, to hide implementation details and so that we don't have to rely on a static empty QModelIndex. Change-Id: I92b3f8451422f2b69bf31f28b387a124fd24ec46 Reviewed-by: Giuseppe D'Angelo (cherry picked from commit 0cd2935ed9d772f0eb06d03201baabd60764ec80) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/itemmodels/qabstractitemmodel.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 7f842e29a6..8da33e0c4e 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -488,17 +488,16 @@ QPersistentModelIndex &QPersistentModelIndex::operator=(const QModelIndex &other } /*! - \fn QPersistentModelIndex::operator const QModelIndex&() const + \fn QPersistentModelIndex::operator QModelIndex() const - Cast operator that returns a const QModelIndex&. + Cast operator that returns a QModelIndex. */ -QPersistentModelIndex::operator const QModelIndex&() const +QPersistentModelIndex::operator QModelIndex() const { - static const QModelIndex invalid; if (d) return d->index; - return invalid; + return QModelIndex(); } /*! -- cgit v1.2.3