mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Fix unclosed file after export.
This commit is contained in:
		
							parent
							
								
									916016f2d4
								
							
						
					
					
						commit
						15620a2fc2
					
				
					 1 changed files with 6 additions and 3 deletions
				
			
		|  | @ -22,6 +22,7 @@ class Zipper::Impl { | |||
| public: | ||||
|     mz_zip_archive arch; | ||||
|     std::string m_zipname; | ||||
|     FILE *cfile = nullptr; | ||||
| 
 | ||||
|     static std::string get_errorstr(mz_zip_error mz_err) | ||||
|     { | ||||
|  | @ -124,15 +125,15 @@ Zipper::Zipper(const std::string &zipfname, e_compression compression) | |||
| 
 | ||||
|     memset(&m_impl->arch, 0, sizeof(m_impl->arch)); | ||||
| 
 | ||||
|     FILE *f = boost::nowide::fopen(zipfname.c_str(), "wb"); | ||||
|     m_impl->cfile = boost::nowide::fopen(zipfname.c_str(), "wb"); | ||||
| 
 | ||||
|     if (f == nullptr) { | ||||
|     if (m_impl->cfile == nullptr) { | ||||
|         m_impl->arch.m_last_error = MZ_ZIP_FILE_OPEN_FAILED; | ||||
|         m_impl->blow_up(); | ||||
|     } | ||||
| 
 | ||||
|     // Initialize the archive data
 | ||||
|     if(!mz_zip_writer_init_cfile(&m_impl->arch, f, 0)) | ||||
|     if(!mz_zip_writer_init_cfile(&m_impl->arch, m_impl->cfile, 0)) | ||||
|         m_impl->blow_up(); | ||||
| } | ||||
| 
 | ||||
|  | @ -151,6 +152,8 @@ Zipper::~Zipper() | |||
|     // The file should be closed no matter what...
 | ||||
|     if(!mz_zip_writer_end(&m_impl->arch)) | ||||
|         BOOST_LOG_TRIVIAL(error) << m_impl->formatted_errorstr(); | ||||
| 
 | ||||
|     if(m_impl->cfile) fclose(m_impl->cfile); | ||||
| } | ||||
| 
 | ||||
| Zipper::Zipper(Zipper &&m): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tamasmeszaros
						tamasmeszaros