FilePath: Return QString copy from toString()

Returning a const reference is different from our usual coding style,
and can lead to crashes when assigning to a const reference, like

const QString &path = filePath.pathAppended("foo").toString();

Make it behave like our other API.

Change-Id: Iab1cf1a944be405227b135c12029f58869893911
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Eike Ziller
2021-04-23 15:01:08 +02:00
parent cac3736b52
commit b264770e17
2 changed files with 2 additions and 2 deletions

View File

@@ -727,7 +727,7 @@ FilePath FilePath::fromUrl(const QUrl &url)
}
/// \returns a QString for passing on to QString based APIs
const QString &FilePath::toString() const
QString FilePath::toString() const
{
return m_data;
}

View File

@@ -78,7 +78,7 @@ public:
static FilePath fromUtf8(const char *filepath, int filepathSize = -1);
static FilePath fromVariant(const QVariant &variant);
const QString &toString() const;
QString toString() const;
QFileInfo toFileInfo() const;
QVariant toVariant() const;