diff options
author | Bartlomiej Moskal <bartlomiej.moskal@qt.io> | 2024-03-11 11:44:00 +0100 |
---|---|---|
committer | Bartlomiej Moskal <bartlomiej.moskal@qt.io> | 2024-03-11 11:22:16 +0000 |
commit | b059737cb2df81ff08548e0f7ca8c6a51b3d73ba (patch) | |
tree | 2e1db55ba5595abe34b8f8ecf6dfc6c9cdaf55eb /src/multimedia | |
parent | 89a952be526c884877e2930801fdc4f845185c5d (diff) |
QMediaStorageLocation: Do not modified path with content scheme
QMediaStorageLocation::generateFileName function is trying to create
whole path with file name according to the provided parameters.
In case when requestedName is an URI content:// scheme (used on Android)
we should not modified it at all. The structure of content URIs is
determined by the content provider implementation. Modifying it may lead
to errors or unintended behavior in application.
Additionally, instead of QStringLiteral start to use modern _L1 string
literal operator.
Pick-to: 6.7 6.6 6.5
Task-number: QTBUG-122224
Change-Id: Ia888a49361da3d2d87365551097d763413350f14
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r-- | src/multimedia/qmediastoragelocation.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/multimedia/qmediastoragelocation.cpp b/src/multimedia/qmediastoragelocation.cpp index 7c1727a31..26dce3a4c 100644 --- a/src/multimedia/qmediastoragelocation.cpp +++ b/src/multimedia/qmediastoragelocation.cpp @@ -53,11 +53,16 @@ QString QMediaStorageLocation::generateFileName(const QString &requestedName, QStandardPaths::StandardLocation type, const QString &extension) { - auto prefix = QLatin1String("clip_"); + using namespace Qt::StringLiterals; + + if (QUrl(requestedName).scheme() == "content"_L1) + return requestedName; + + auto prefix = "clip_"_L1; switch (type) { - case QStandardPaths::PicturesLocation: prefix = QLatin1String("image_"); break; - case QStandardPaths::MoviesLocation: prefix = QLatin1String("video_"); break; - case QStandardPaths::MusicLocation: prefix = QLatin1String("record_"); break; + case QStandardPaths::PicturesLocation: prefix = "image_"_L1; break; + case QStandardPaths::MoviesLocation: prefix = "video_"_L1; break; + case QStandardPaths::MusicLocation: prefix = "record_"_L1; break; default: break; } |