summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2015-04-16 10:32:53 +0200
committerRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2015-05-06 07:59:42 +0000
commit9166e7a50ad15da7ca4907dd99a9bef68a67ab5b (patch)
tree6da4cfe3192b68e92a233fe9b482f0ce3d2733bb /src
parent1c7e3a2a33b890a19bbac57cd068aef04c134527 (diff)
ios: resolve m_assetUrl already in QIOSFileEngineAssetsLibrary::setFileName()
Resolve m_assetUrl already when setting file name. The variable will be used several places in patches that follows. At the same time, change the logic to be more robust to work around QDir removing slashes (both single a double) after the scheme. In the end, what matters is that we still recognize the file name as an asset url, and that we can restore the original url based on the hash-tag contained inside the file name. Change-Id: I988c6a73b2484e46d63917b442c13aa5a3666787 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/ios/qiosfileengineassetslibrary.h1
-rw-r--r--src/plugins/platforms/ios/qiosfileengineassetslibrary.mm26
2 files changed, 13 insertions, 14 deletions
diff --git a/src/plugins/platforms/ios/qiosfileengineassetslibrary.h b/src/plugins/platforms/ios/qiosfileengineassetslibrary.h
index 043e101a21..0f5eb1af8a 100644
--- a/src/plugins/platforms/ios/qiosfileengineassetslibrary.h
+++ b/src/plugins/platforms/ios/qiosfileengineassetslibrary.h
@@ -59,6 +59,7 @@ public:
private:
QString m_fileName;
+ QString m_assetUrl;
qint64 m_offset;
mutable QIOSAssetData *m_data;
diff --git a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
index 73bfc2a87f..46a43c886e 100644
--- a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
+++ b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
@@ -130,10 +130,10 @@ QPointer<QIOSAssetData> QIOSAssetData::g_currentAssetData = 0;
// -------------------------------------------------------------------------
QIOSFileEngineAssetsLibrary::QIOSFileEngineAssetsLibrary(const QString &fileName)
- : m_fileName(fileName)
- , m_offset(0)
+ : m_offset(0)
, m_data(0)
{
+ setFileName(fileName);
}
QIOSFileEngineAssetsLibrary::~QIOSFileEngineAssetsLibrary()
@@ -143,18 +143,8 @@ QIOSFileEngineAssetsLibrary::~QIOSFileEngineAssetsLibrary()
ALAsset *QIOSFileEngineAssetsLibrary::loadAsset() const
{
- if (!m_data) {
- // QUrl::fromLocalFile() will remove double slashes. Since the asset url is passed around as a file
- // name in the app (and converted to/from a file url, e.g in QFileDialog), we need to check if we still
- // have two leading slashes after the scheme, and restore the second slash if not.
- QString assetUrl = m_fileName;
- const int index = 16; // "assets-library://"
- if (assetUrl[index] != QLatin1Char('/'))
- assetUrl.insert(index, '/');
-
- m_data = new QIOSAssetData(assetUrl, const_cast<QIOSFileEngineAssetsLibrary *>(this));
- }
-
+ if (!m_data)
+ m_data = new QIOSAssetData(m_assetUrl, const_cast<QIOSFileEngineAssetsLibrary *>(this));
return m_data->m_asset;
}
@@ -245,6 +235,14 @@ void QIOSFileEngineAssetsLibrary::setFileName(const QString &file)
if (m_data)
close();
m_fileName = file;
+ // QUrl::fromLocalFile() will remove double slashes. Since the asset url is
+ // passed around as a file name in the app (and converted to/from a file url, e.g
+ // in QFileDialog), we need to ensure that m_assetUrl ends up being valid.
+ int index = file.indexOf(QLatin1String("asset.JPG?"));
+ if (index == -1)
+ m_assetUrl = QLatin1String("assets-library://");
+ else
+ m_assetUrl = QLatin1String("assets-library://asset/") + file.mid(index);
}
QStringList QIOSFileEngineAssetsLibrary::entryList(QDir::Filters filters, const QStringList &filterNames) const