Android: avoid duplicate paths from QStandardPaths::standardLocations()
Don't return duplicate path entries from calling QStandardPaths::standardLocations() and as a pass by no empty entries either. Task-number: QTBUG-104892 Change-Id: If05b20d2c07d75428cb572d9549a39cf21bdef99 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit 30014ed850bbe62005b4aa789586b01c1281cab4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3562a06809
commit
2e94481c51
@ -172,59 +172,47 @@ QString QStandardPaths::writableLocation(StandardLocation type)
|
|||||||
|
|
||||||
QStringList QStandardPaths::standardLocations(StandardLocation type)
|
QStringList QStandardPaths::standardLocations(StandardLocation type)
|
||||||
{
|
{
|
||||||
|
QStringList locations;
|
||||||
|
|
||||||
if (type == MusicLocation) {
|
if (type == MusicLocation) {
|
||||||
return QStringList() << writableLocation(type)
|
locations << getExternalFilesDir("DIRECTORY_MUSIC")
|
||||||
<< getExternalFilesDir("DIRECTORY_MUSIC")
|
<< getExternalFilesDir("DIRECTORY_PODCASTS")
|
||||||
<< getExternalFilesDir("DIRECTORY_PODCASTS")
|
<< getExternalFilesDir("DIRECTORY_NOTIFICATIONS")
|
||||||
<< getExternalFilesDir("DIRECTORY_NOTIFICATIONS")
|
<< getExternalFilesDir("DIRECTORY_ALARMS");
|
||||||
<< getExternalFilesDir("DIRECTORY_ALARMS");
|
} else if (type == MoviesLocation) {
|
||||||
}
|
locations << getExternalFilesDir("DIRECTORY_MOVIES");
|
||||||
|
} else if (type == PicturesLocation) {
|
||||||
if (type == MoviesLocation) {
|
locations << getExternalFilesDir("DIRECTORY_PICTURES");
|
||||||
return QStringList() << writableLocation(type)
|
} else if (type == DocumentsLocation) {
|
||||||
<< getExternalFilesDir("DIRECTORY_MOVIES");
|
locations << getExternalFilesDir("DIRECTORY_DOCUMENTS");
|
||||||
}
|
} else if (type == DownloadLocation) {
|
||||||
|
locations << getExternalFilesDir("DIRECTORY_DOWNLOADS");
|
||||||
if (type == PicturesLocation) {
|
} else if (type == AppDataLocation || type == AppLocalDataLocation) {
|
||||||
return QStringList() << writableLocation(type)
|
locations << getExternalFilesDir();
|
||||||
<< getExternalFilesDir("DIRECTORY_PICTURES");
|
} else if (type == CacheLocation) {
|
||||||
}
|
locations << getExternalCacheDir();
|
||||||
|
} else if (type == FontsLocation) {
|
||||||
if (type == DocumentsLocation) {
|
|
||||||
return QStringList() << writableLocation(type)
|
|
||||||
<< getExternalFilesDir("DIRECTORY_DOCUMENTS");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == DownloadLocation) {
|
|
||||||
return QStringList() << writableLocation(type)
|
|
||||||
<< getExternalFilesDir("DIRECTORY_DOWNLOADS");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == AppDataLocation || type == AppLocalDataLocation) {
|
|
||||||
return QStringList() << writableLocation(type)
|
|
||||||
<< getExternalFilesDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == CacheLocation) {
|
|
||||||
return QStringList() << writableLocation(type)
|
|
||||||
<< getExternalCacheDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == FontsLocation) {
|
|
||||||
QString &fontLocation = (*androidDirCache)[QStringLiteral("FONT_LOCATION")];
|
QString &fontLocation = (*androidDirCache)[QStringLiteral("FONT_LOCATION")];
|
||||||
if (!fontLocation.isEmpty())
|
if (!fontLocation.isEmpty()) {
|
||||||
return QStringList(fontLocation);
|
locations << fontLocation;
|
||||||
|
} else {
|
||||||
const QByteArray ba = qgetenv("QT_ANDROID_FONT_LOCATION");
|
const QByteArray ba = qgetenv("QT_ANDROID_FONT_LOCATION");
|
||||||
if (!ba.isEmpty())
|
if (!ba.isEmpty()) {
|
||||||
return QStringList((fontLocation = QDir::cleanPath(QString::fromLocal8Bit(ba))));
|
locations << (fontLocation = QDir::cleanPath(QString::fromLocal8Bit(ba)));
|
||||||
|
} else {
|
||||||
// Don't cache the fallback, as we might just have been called before
|
// Don't cache the fallback, as we might just have been called before
|
||||||
// QT_ANDROID_FONT_LOCATION has been set.
|
// QT_ANDROID_FONT_LOCATION has been set.
|
||||||
return QStringList("/system/fonts"_L1);
|
locations << "/system/fonts"_L1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QStringList(writableLocation(type));
|
const QString writable = writableLocation(type);
|
||||||
|
if (!writable.isEmpty())
|
||||||
|
locations.prepend(writable);
|
||||||
|
|
||||||
|
locations.removeDuplicates();
|
||||||
|
return locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user