summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-12-02 15:40:14 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-04 06:00:50 +0000
commit57e9d9e38e7cb52011438133dd7cdd749a410d00 (patch)
treef330551eb73d623335b1d506620e2516af774d3b /src/corelib/itemmodels
parent6012285e7dedb4364e2db087b7d5cbfc2973320a (diff)
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 <giuseppe.dangelo@kdab.com> (cherry picked from commit 0cd2935ed9d772f0eb06d03201baabd60764ec80) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/itemmodels')
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp9
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h2
2 files changed, 5 insertions, 6 deletions
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();
}
/*!
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 7479f4b043..789ed60ce4 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -226,7 +226,7 @@ public:
bool operator==(const QModelIndex &other) const;
bool operator!=(const QModelIndex &other) const;
QPersistentModelIndex &operator=(const QModelIndex &other);
- operator const QModelIndex&() const;
+ operator QModelIndex() const;
int row() const;
int column() const;
void *internalPointer() const;