Skip to content

Commit b503913

Browse files
committed
fix: set parent pointer on file to be the same shared pointer from mFileToArchive
1 parent be3a87e commit b503913

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/resource/archive/ArchiveManager.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@ std::shared_ptr<File> ArchiveManager::LoadFileRaw(const std::string& filePath) {
6767
return nullptr;
6868
}
6969

70-
const auto archive = mFileToArchive[CRC64(filePath.c_str())];
71-
if (archive == nullptr) {
72-
return nullptr;
73-
}
74-
75-
return archive->LoadFileRaw(filePath);
70+
return LoadFileRaw(CRC64(filePath.c_str()));
7671
}
7772

7873
std::shared_ptr<File> ArchiveManager::LoadFileRaw(uint64_t hash) {
@@ -81,7 +76,9 @@ std::shared_ptr<File> ArchiveManager::LoadFileRaw(uint64_t hash) {
8176
return nullptr;
8277
}
8378

84-
return archive->LoadFileRaw(hash);
79+
auto file = archive->LoadFileRaw(hash);
80+
file->Parent = archive;
81+
return file;
8582
}
8683

8784
bool ArchiveManager::HasFile(const std::string& filePath) {

src/resource/archive/O2rArchive.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ std::shared_ptr<File> O2rArchive::LoadFileRaw(const std::string& filePath) {
5353
SPDLOG_TRACE("Error closing file {} in zip archive {}.", filePath, GetPath());
5454
}
5555

56-
fileToLoad->Parent = dynamic_pointer_cast<Archive>(std::make_shared<O2rArchive>(std::move(*this)));
5756
fileToLoad->IsLoaded = true;
5857

5958
return fileToLoad;

src/resource/archive/OtrArchive.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ std::shared_ptr<File> OtrArchive::LoadFileRaw(const std::string& filePath) {
5050
SPDLOG_ERROR("({}) Failed to close file {} from mpq archive {}", GetLastError(), filePath, GetPath());
5151
}
5252

53-
fileToLoad->Parent = dynamic_pointer_cast<Archive>(std::make_shared<OtrArchive>(std::move(*this)));
5453
fileToLoad->IsLoaded = true;
5554

5655
return fileToLoad;

0 commit comments

Comments
 (0)