core: reference scanned paths by QDir over QString

Fixes a bug introduced in 3e2ce40 where a directory imported with a
"../name" path import would be passed to scanDir as ending in '/' which
created an invalid duplicate scan entry.
This commit is contained in:
outfoxxed 2025-10-31 00:56:30 -07:00
parent db1777c20b
commit fc704e6b5d
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 8 additions and 7 deletions

View file

@ -19,12 +19,13 @@
QS_LOGGING_CATEGORY(logQmlScanner, "quickshell.qmlscanner", QtWarningMsg);
void QmlScanner::scanDir(const QString& path) {
if (this->scannedDirs.contains(path)) return;
this->scannedDirs.push_back(path);
void QmlScanner::scanDir(const QDir& dir) {
if (this->scannedDirs.contains(dir)) return;
this->scannedDirs.push_back(dir);
const auto& path = dir.path();
qCDebug(logQmlScanner) << "Scanning directory" << path;
auto dir = QDir(path);
struct Entry {
QString name;
@ -166,7 +167,7 @@ bool QmlScanner::scanQmlFile(const QString& path, bool& singleton, bool& interna
auto currentdir = QDir(QFileInfo(path).absolutePath());
// the root can never be a singleton so it dosent matter if we skip it
this->scanDir(currentdir.path());
this->scanDir(currentdir);
for (auto& import: imports) {
QString ipath;

View file

@ -16,10 +16,10 @@ public:
QmlScanner() = default;
QmlScanner(const QDir& rootPath): rootPath(rootPath) {}
void scanDir(const QString& path);
void scanDir(const QDir& dir);
void scanQmlRoot(const QString& path);
QVector<QString> scannedDirs;
QVector<QDir> scannedDirs;
QVector<QString> scannedFiles;
QHash<QString, QString> fileIntercepts;