Replace unique_ptr with raw pointer to avoid destructing stream

This commit is contained in:
Joshua Hyatt
2020-08-29 22:21:34 -06:00
parent 48ec3ef458
commit c769f8d4ad

View File

@@ -107,8 +107,8 @@ const aiImporterDesc *ObjFileImporter::GetInfo() const {
void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
// Read file into memory
static const std::string mode = "rb";
std::unique_ptr<IOStream> fileStream(pIOHandler->Open(file, mode));
if (!fileStream.get()) {
IOStream *fileStream = pIOHandler->Open(file, mode);
if (!fileStream) {
throw DeadlyImportError("Failed to open file " + file + ".");
}
@@ -119,10 +119,10 @@ void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, I
}
IOStreamBuffer<char> streamedBuffer;
streamedBuffer.open(fileStream.get());
streamedBuffer.open(fileStream);
// Allocate buffer and read file into it
//TextFileToBuffer( fileStream.get(),m_Buffer);
//TextFileToBuffer( fileStream,m_Buffer);
// Get the model name
std::string modelName, folderName;
@@ -145,6 +145,8 @@ void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, I
streamedBuffer.close();
pIOHandler->Close(fileStream);
// Clean up allocated storage for the next import
m_Buffer.clear();