forked from qt-creator/qt-creator
QmlDesigner: Fix importing existing asset with different capitalization
In case sensitive file systems, revert to old capitalization after reimporting existing asset with different capitalization. Change-Id: If26443b34e408c84aeb12940262c8b9f696f0bbf Fixes: QDS-1958 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -280,7 +280,16 @@ void ItemLibraryAssetImporter::parseQuick3DAsset(const QString &file, const QVar
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString originalAssetName = assetName;
|
||||||
if (targetDir.exists(assetName)) {
|
if (targetDir.exists(assetName)) {
|
||||||
|
// If we have a file system with case insensitive filenames, assetName may be
|
||||||
|
// different from the existing name. Modify assetName to ensure exact match to
|
||||||
|
// the overwritten old asset capitalization
|
||||||
|
const QStringList assetDirs = targetDir.entryList({assetName}, QDir::Dirs);
|
||||||
|
if (assetDirs.size() == 1) {
|
||||||
|
assetName = assetDirs[0];
|
||||||
|
targetDirPath = targetDir.filePath(assetName);
|
||||||
|
}
|
||||||
if (!confirmAssetOverwrite(assetName)) {
|
if (!confirmAssetOverwrite(assetName)) {
|
||||||
addWarning(tr("Skipped import of existing asset: \"%1\"").arg(assetName));
|
addWarning(tr("Skipped import of existing asset: \"%1\"").arg(assetName));
|
||||||
return;
|
return;
|
||||||
@@ -306,6 +315,13 @@ void ItemLibraryAssetImporter::parseQuick3DAsset(const QString &file, const QVar
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (originalAssetName != assetName) {
|
||||||
|
// Fix the generated qml file name
|
||||||
|
const QString assetQml = originalAssetName + ".qml";
|
||||||
|
if (outDir.exists(assetQml))
|
||||||
|
outDir.rename(assetQml, assetName + ".qml");
|
||||||
|
}
|
||||||
|
|
||||||
QHash<QString, QString> assetFiles;
|
QHash<QString, QString> assetFiles;
|
||||||
const int outDirPathSize = outDir.path().size();
|
const int outDirPathSize = outDir.path().size();
|
||||||
auto insertAsset = [&](const QString &filePath) {
|
auto insertAsset = [&](const QString &filePath) {
|
||||||
|
Reference in New Issue
Block a user