Android: Don't recurse into directories inside the assets when iterating
When iterating, it should only return what is in the specified path and not the contents of the sub-directories inside the given path in addition. Change-Id: Iad56f075c22fdf1c633582e37444e26520c24a73 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
parent
09c5dfb732
commit
eaf7f572bf
@ -202,9 +202,7 @@ public:
|
||||
const QString &path)
|
||||
: QAbstractFileEngineIterator(filters, nameFilters)
|
||||
{
|
||||
m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(path), true));
|
||||
if (m_stack.last()->empty())
|
||||
m_stack.pop_back();
|
||||
m_currentIterator = FolderIterator::fromCache(cleanedAssetPath(path), true);
|
||||
}
|
||||
|
||||
QFileInfo currentFileInfo() const override
|
||||
@ -228,36 +226,23 @@ public:
|
||||
|
||||
bool hasNext() const override
|
||||
{
|
||||
if (m_stack.empty())
|
||||
if (!m_currentIterator)
|
||||
return false;
|
||||
if (!m_stack.last()->hasNext()) {
|
||||
m_stack.pop_back();
|
||||
return hasNext();
|
||||
}
|
||||
return true;
|
||||
return m_currentIterator->hasNext();
|
||||
}
|
||||
|
||||
QString next() override
|
||||
{
|
||||
if (m_stack.empty()) {
|
||||
m_currentIterator.reset();
|
||||
if (!m_currentIterator)
|
||||
return {};
|
||||
}
|
||||
m_currentIterator = m_stack.last();
|
||||
auto res = m_currentIterator->next();
|
||||
if (!res)
|
||||
return {};
|
||||
if (res->second.type == AssetItem::Type::Folder) {
|
||||
m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(currentFilePath()), true));
|
||||
if (m_stack.last()->empty())
|
||||
m_stack.pop_back();
|
||||
}
|
||||
return res->first;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable QSharedPointer<FolderIterator> m_currentIterator;
|
||||
mutable QVector<QSharedPointer<FolderIterator>> m_stack;
|
||||
QSharedPointer<FolderIterator> m_currentIterator;
|
||||
};
|
||||
|
||||
class AndroidAbstractFileEngine: public QAbstractFileEngine
|
||||
|
Loading…
x
Reference in New Issue
Block a user