mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 21:09:42 +00:00
Add ReadersCache::clear
This commit is contained in:
parent
5f0fe8097c
commit
77d554594f
4 changed files with 16 additions and 8 deletions
|
@ -1065,11 +1065,9 @@ int CSMWorld::Data::startLoading(const std::filesystem::path& path, bool base, b
|
||||||
{
|
{
|
||||||
Log(Debug::Info) << "Loading content file " << path;
|
Log(Debug::Info) << "Loading content file " << path;
|
||||||
|
|
||||||
if (!mReaders)
|
|
||||||
mReaders.emplace();
|
|
||||||
mDialogue = nullptr;
|
mDialogue = nullptr;
|
||||||
|
|
||||||
auto reader = mReaders->get(mReaderIndex++);
|
ESM::ReadersCache::BusyItem reader = mReaders.get(mReaderIndex++);
|
||||||
reader->setEncoder(&mEncoder);
|
reader->setEncoder(&mEncoder);
|
||||||
reader->open(path);
|
reader->open(path);
|
||||||
|
|
||||||
|
@ -1133,14 +1131,14 @@ void CSMWorld::Data::loadFallbackEntries()
|
||||||
|
|
||||||
bool CSMWorld::Data::continueLoading(CSMDoc::Messages& messages)
|
bool CSMWorld::Data::continueLoading(CSMDoc::Messages& messages)
|
||||||
{
|
{
|
||||||
if (mReaderIndex == 0 || !mReaders)
|
if (mReaderIndex == 0)
|
||||||
throw std::logic_error("can't continue loading, because no load has been started");
|
throw std::logic_error("can't continue loading, because no load has been started");
|
||||||
ESM::ReadersCache::BusyItem reader = mReaders->get(mReaderIndex - 1);
|
ESM::ReadersCache::BusyItem reader = mReaders.get(mReaderIndex - 1);
|
||||||
if (!reader->isOpen())
|
if (!reader->isOpen())
|
||||||
throw std::logic_error("can't continue loading, because no load has been started");
|
throw std::logic_error("can't continue loading, because no load has been started");
|
||||||
reader->setEncoder(&mEncoder);
|
reader->setEncoder(&mEncoder);
|
||||||
reader->setIndex(static_cast<int>(mReaderIndex - 1));
|
reader->setIndex(static_cast<int>(mReaderIndex - 1));
|
||||||
reader->resolveParentFileIndices(*mReaders);
|
reader->resolveParentFileIndices(mReaders);
|
||||||
|
|
||||||
if (!reader->hasMoreRecs())
|
if (!reader->hasMoreRecs())
|
||||||
{
|
{
|
||||||
|
@ -1411,7 +1409,7 @@ void CSMWorld::Data::finishLoading()
|
||||||
mTopicInfos.sort(mTopicInfoOrder);
|
mTopicInfos.sort(mTopicInfoOrder);
|
||||||
mJournalInfos.sort(mJournalInfoOrder);
|
mJournalInfos.sort(mJournalInfoOrder);
|
||||||
// Release file locks so we can actually write to the file we're editing
|
// Release file locks so we can actually write to the file we're editing
|
||||||
mReaders.reset();
|
mReaders.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSMWorld::Data::hasId(const std::string& id) const
|
bool CSMWorld::Data::hasId(const std::string& id) const
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace CSMWorld
|
||||||
std::unique_ptr<ActorAdapter> mActorAdapter;
|
std::unique_ptr<ActorAdapter> mActorAdapter;
|
||||||
std::vector<QAbstractItemModel*> mModels;
|
std::vector<QAbstractItemModel*> mModels;
|
||||||
std::map<UniversalId::Type, QAbstractItemModel*> mModelIndex;
|
std::map<UniversalId::Type, QAbstractItemModel*> mModelIndex;
|
||||||
std::optional<ESM::ReadersCache> mReaders;
|
ESM::ReadersCache mReaders;
|
||||||
const ESM::Dialogue* mDialogue; // last loaded dialogue
|
const ESM::Dialogue* mDialogue; // last loaded dialogue
|
||||||
bool mBase;
|
bool mBase;
|
||||||
bool mProject;
|
bool mProject;
|
||||||
|
|
|
@ -86,4 +86,12 @@ namespace ESM
|
||||||
it->mState = State::Closed;
|
it->mState = State::Closed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReadersCache::clear()
|
||||||
|
{
|
||||||
|
mIndex.clear();
|
||||||
|
mBusyItems.clear();
|
||||||
|
mFreeItems.clear();
|
||||||
|
mClosedItems.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ namespace ESM
|
||||||
|
|
||||||
BusyItem get(std::size_t index);
|
BusyItem get(std::size_t index);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::size_t mCapacity;
|
const std::size_t mCapacity;
|
||||||
std::map<std::size_t, std::list<Item>::iterator> mIndex;
|
std::map<std::size_t, std::list<Item>::iterator> mIndex;
|
||||||
|
|
Loading…
Reference in a new issue