Adpat to changes in QAbstractFileEngine/Iterator in qtbase

- Replace hasNext()/next() with a `bool advance()` method
- Replace QAFE::FileTime with QFile::FileTime, they are identical
- QAFE methods now return std::unique_ptr, which matches reality as call
  sites stored the pointers in a std::unique_ptr anyway

FileIteratorWrapper:
State::BaseIteratorEnd is only needed when using hasNext()/next(),
hasNext() changes m_status to State::BaseIteratorEnd, then next() checks
that and changes m_status to State::Ended; this isn't needed with
advance() since it's only one method.

Change-Id: I4414f334715237a2fc13ace6f4733d975e2cfaa3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
(cherry picked from commit ba3f0bc841)
This commit is contained in:
Ahmad Samir
2023-12-26 10:51:11 +02:00
parent 2f725cd559
commit 6babc022d5
9 changed files with 155 additions and 18 deletions

View File

@@ -473,16 +473,25 @@ ComponentCompleteDisabler::~ComponentCompleteDisabler()
class QrcEngineHandler : public QAbstractFileEngineHandler
{
public:
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
std::unique_ptr<QAbstractFileEngine> create(const QString &fileName) const final;
#else
QAbstractFileEngine *create(const QString &fileName) const final;
#endif
};
QAbstractFileEngine *QrcEngineHandler::create(const QString &fileName) const
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
std::unique_ptr<QAbstractFileEngine>
#else
QAbstractFileEngine *
#endif
QrcEngineHandler::create(const QString &fileName) const
{
if (fileName.startsWith(":/qt-project.org"))
return nullptr;
return {};
if (fileName.startsWith(":/qtquickplugin"))
return nullptr;
return {};
if (fileName.startsWith(":/")) {
const QStringList searchPaths = qmlDesignerRCPath().split(';');
@@ -493,18 +502,22 @@ QAbstractFileEngine *QrcEngineHandler::create(const QString &fileName) const
fixedPath.replace(":" + qrcDefintion.first(), qrcDefintion.last() + '/');
if (fileName == fixedPath)
return nullptr;
return {};
if (QFileInfo::exists(fixedPath)) {
fixedPath.replace("//", "/");
fixedPath.replace('\\', '/');
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
return std::make_unique<QFSFileEngine>(fixedPath);
#else
return new QFSFileEngine(fixedPath);
#endif
}
}
}
}
return nullptr;
return {};
}
static QrcEngineHandler* s_qrcEngineHandler = nullptr;