Fix infinite loop when iterating content uri sub-files/dirs

make QAbstractFileEngineIterator::currentFilePath() virtual
and implement it under AndroidContentFileEngine to return
current fileName because content uris shouldn't be constructed
manaully like normal file paths.

Pick-to: 6.4 6.2
Fixes: QTBUG-104776
Change-Id: I4643a73a3bd4019bedaa056c35468117bcec18dc
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
This commit is contained in:
Assam Boudjelthia 2022-11-22 14:02:11 +02:00
parent 2f440169c0
commit f3c998510d
4 changed files with 8 additions and 2 deletions

View File

@ -206,7 +206,7 @@ public:
virtual QString currentFileName() const = 0;
virtual QFileInfo currentFileInfo() const;
QString currentFilePath() const;
virtual QString currentFilePath() const;
protected:
enum EntryInfoType {

View File

@ -200,3 +200,8 @@ QString AndroidContentFileEngineIterator::currentFileName() const
return QString();
return m_entries.at(m_index - 1);
}
QString AndroidContentFileEngineIterator::currentFilePath() const
{
return currentFileName();
}

View File

@ -40,6 +40,7 @@ public:
QString next() override;
bool hasNext() const override;
QString currentFileName() const override;
QString currentFilePath() const override;
private:
mutable QStringList m_entries;
mutable int m_index = -1;

View File

@ -186,7 +186,7 @@ public:
return m_currentIterator->currentFileName();
}
virtual QString currentFilePath() const
QString currentFilePath() const override
{
if (!m_currentIterator)
return {};