From 3dfc3d7022b14484d2a4d64e580368bb0c56f0b8 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 1 Jun 2025 03:21:19 +0300 Subject: [PATCH] Don't use item(QString) while marking new content files --- components/contentselector/model/contentmodel.cpp | 13 ++++--------- components/contentselector/model/contentmodel.hpp | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index d5202edc44..b7afe67df4 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -469,7 +469,7 @@ void ContentSelectorModel::ContentModel::addFiles(const QString& path, bool newf file->setFilePath(info.absoluteFilePath()); if (add) addFile(newFile.release()); - setNew(file->fileName(), newfiles); + setNew(file, newfiles); continue; } @@ -525,7 +525,7 @@ void ContentSelectorModel::ContentModel::addFiles(const QString& path, bool newf // Put the file in the table if (add) addFile(newFile.release()); - setNew(file->fileName(), newfiles); + setNew(file, newfiles); } catch (std::runtime_error& e) { @@ -664,17 +664,12 @@ bool ContentSelectorModel::ContentModel::isNew(const QString& filepath) const return it.value(); } -void ContentSelectorModel::ContentModel::setNew(const QString& filepath, bool isNew) +void ContentSelectorModel::ContentModel::setNew(const EsmFile* file, bool isNew) { - if (filepath.isEmpty()) - return; - - const EsmFile* file = item(filepath); - if (!file) return; - mNewFiles[filepath] = isNew; + mNewFiles[file->fileName()] = isNew; } void ContentSelectorModel::ContentModel::setNonUserContent(const QStringList& fileList) diff --git a/components/contentselector/model/contentmodel.hpp b/components/contentselector/model/contentmodel.hpp index 201af3a73b..cf182263f9 100644 --- a/components/contentselector/model/contentmodel.hpp +++ b/components/contentselector/model/contentmodel.hpp @@ -61,7 +61,7 @@ namespace ContentSelectorModel bool isEnabled(const QModelIndex& index) const; bool setCheckState(const EsmFile* file, bool isChecked); bool isNew(const QString& filepath) const; - void setNew(const QString& filepath, bool isChecked); + void setNew(const EsmFile* file, bool isChecked); void setNonUserContent(const QStringList& fileList); void setContentList(const QStringList& fileList); ContentFileList checkedItems() const;