QStandardItemModel: don't leak in mimeData()
When an invalid index is given to QStandardItemModel::mimeData() the function bails out with a warning and returns a nullptr. But the allocated data from QAIM::modelData() was not freed. Pick-to: 6.5 6.2 5.15 Task-number: QTBUG-116532 Change-Id: Ibce9d51ea09d45f1b0eb3ca980aaff141af5bf68 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 37048d04172430ee88c9cd8f7589c51a5bbcd5f4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
74d460959b
commit
ef144f2e30
@ -3099,13 +3099,13 @@ QStringList QStandardItemModel::mimeTypes() const
|
||||
*/
|
||||
QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
QMimeData *data = QAbstractItemModel::mimeData(indexes);
|
||||
std::unique_ptr<QMimeData> data(QAbstractItemModel::mimeData(indexes));
|
||||
if (!data)
|
||||
return nullptr;
|
||||
|
||||
const QString format = qStandardItemModelDataListMimeType();
|
||||
if (!mimeTypes().contains(format))
|
||||
return data;
|
||||
return data.release();
|
||||
QByteArray encoded;
|
||||
QDataStream stream(&encoded, QIODevice::WriteOnly);
|
||||
|
||||
@ -3157,7 +3157,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
|
||||
}
|
||||
|
||||
data->setData(format, encoded);
|
||||
return data;
|
||||
return data.release();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user