mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Keep ZIP file objects in std::unique_ptr<> to clarify ownership.
This commit is contained in:
parent
ac9954972d
commit
b176cb421b
2 changed files with 4 additions and 11 deletions
|
@ -44,8 +44,6 @@ lcPiecesLibrary::lcPiecesLibrary()
|
|||
Dir.mkpath(mCachePath);
|
||||
|
||||
mNumOfficialPieces = 0;
|
||||
mZipFiles[LC_ZIPFILE_OFFICIAL] = nullptr;
|
||||
mZipFiles[LC_ZIPFILE_UNOFFICIAL] = nullptr;
|
||||
mBuffersDirty = false;
|
||||
mHasUnofficial = false;
|
||||
mCancelLoading = false;
|
||||
|
@ -77,9 +75,7 @@ void lcPiecesLibrary::Unload()
|
|||
mTextures.clear();
|
||||
|
||||
mNumOfficialPieces = 0;
|
||||
delete mZipFiles[LC_ZIPFILE_OFFICIAL];
|
||||
mZipFiles[LC_ZIPFILE_OFFICIAL] = nullptr;
|
||||
delete mZipFiles[LC_ZIPFILE_UNOFFICIAL];
|
||||
mZipFiles[LC_ZIPFILE_UNOFFICIAL] = nullptr;
|
||||
}
|
||||
|
||||
|
@ -317,15 +313,10 @@ bool lcPiecesLibrary::OpenArchive(const QString& FileName, lcZipFileType ZipFile
|
|||
|
||||
bool lcPiecesLibrary::OpenArchive(std::unique_ptr<lcFile> File, const QString& FileName, lcZipFileType ZipFileType)
|
||||
{
|
||||
lcZipFile* ZipFile = new lcZipFile();
|
||||
std::unique_ptr<lcZipFile> ZipFile(new lcZipFile());
|
||||
|
||||
if (!ZipFile->OpenRead(std::move(File)))
|
||||
{
|
||||
delete ZipFile;
|
||||
return false;
|
||||
}
|
||||
|
||||
mZipFiles[ZipFileType] = ZipFile;
|
||||
|
||||
for (int FileIdx = 0; FileIdx < ZipFile->mFiles.GetSize(); FileIdx++)
|
||||
{
|
||||
|
@ -424,6 +415,8 @@ bool lcPiecesLibrary::OpenArchive(std::unique_ptr<lcFile> File, const QString& F
|
|||
}
|
||||
}
|
||||
|
||||
mZipFiles[ZipFileType] = std::move(ZipFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ protected:
|
|||
|
||||
QString mCachePath;
|
||||
qint64 mArchiveCheckSum[4];
|
||||
lcZipFile* mZipFiles[LC_NUM_ZIPFILES];
|
||||
std::unique_ptr<lcZipFile> mZipFiles[LC_NUM_ZIPFILES];
|
||||
bool mHasUnofficial;
|
||||
bool mCancelLoading;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue