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>
This commit is contained in:
parent
2f747bb57c
commit
6bc1a1ec2f
@ -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)
|
if (d)
|
||||||
return d->index;
|
return d->index;
|
||||||
return invalid;
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -226,7 +226,7 @@ public:
|
|||||||
bool operator==(const QModelIndex &other) const;
|
bool operator==(const QModelIndex &other) const;
|
||||||
bool operator!=(const QModelIndex &other) const;
|
bool operator!=(const QModelIndex &other) const;
|
||||||
QPersistentModelIndex &operator=(const QModelIndex &other);
|
QPersistentModelIndex &operator=(const QModelIndex &other);
|
||||||
operator const QModelIndex&() const;
|
operator QModelIndex() const;
|
||||||
int row() const;
|
int row() const;
|
||||||
int column() const;
|
int column() const;
|
||||||
void *internalPointer() const;
|
void *internalPointer() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user