Skip to content

Commit

Permalink
fix: deadlock issue with AddItem
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Dec 23, 2021
1 parent f96ae17 commit c5412d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 1 addition & 3 deletions Code/client/Games/ExtraData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ bool BSExtraDataList::Add(ExtraData aType, BSExtraData* apNewData)
if (Contains(aType))
return false;

lock.Lock();
BSScopedLock<BSRecursiveLock> _(lock);

BSExtraData* pNext = data;
data = apNewData;
apNewData->next = pNext;
SetType(aType, false);

lock.Unlock();

return true;
}

Expand Down
12 changes: 9 additions & 3 deletions Code/client/Services/Generic/TestService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <ExtraData/ExtraWornLeft.h>
#include <Forms/EnchantmentItem.h>
#include <Forms/AlchemyItem.h>
#include <Structs/Container.h>
#endif

#include <imgui.h>
Expand Down Expand Up @@ -185,9 +186,14 @@ void TestService::OnUpdate(const UpdateEvent& acUpdateEvent) noexcept
auto fullContainer = PlayerCharacter::Get()->GetFullContainer();
spdlog::info("Full container entries: {}", fullContainer.Entries.size());

auto pActor = m_actors[0];
auto* pObj = RTTI_CAST(TESForm::GetById(0x139B9), TESForm, TESBoundObject);
pActor->AddObjectToContainer(pObj, nullptr, 1, nullptr);
for (auto entry : fullContainer.Entries)
{
if (entry.BaseId.BaseId == 0x139b9)
{
m_actors[0]->AddItem(entry);
break;
}
}

/*
auto* pActor = (Actor*)TESForm::GetById(0xFF000DA5);
Expand Down

0 comments on commit c5412d2

Please sign in to comment.