summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Moskal <bartlomiej.moskal@qt.io>2024-03-11 11:44:00 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-12 10:19:20 +0000
commit582ad5aa6cd650d90d3e3d74a882e3b5bb2c8ff2 (patch)
treee43e0a2284c1829309b2667996988720f686f283
parent22a2cfa9c8ed6f0f33314479dfb8e6635aa05b5e (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.5 Task-number: QTBUG-122224 Change-Id: Ia888a49361da3d2d87365551097d763413350f14 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> (cherry picked from commit b059737cb2df81ff08548e0f7ca8c6a51b3d73ba) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 200714759c52c18f74bd7466c29a5f02089f1317)
-rw-r--r--src/multimedia/qmediastoragelocation.cpp13
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;
}