Browse Source

Replace unique_ptr with raw pointer to avoid destructing stream

Joshua Hyatt 5 years ago
parent
commit
c769f8d4ad
1 changed files with 6 additions and 4 deletions
  1. 6 4
      code/AssetLib/Obj/ObjFileImporter.cpp

+ 6 - 4
code/AssetLib/Obj/ObjFileImporter.cpp

@@ -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();