mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 22:45:58 +08:00
Cancelling "fix by netfabb" may leave output file handler to a temp file
opened. This is fixed now. Fixes Memory leak when exporting to netfabb and cancelling #7632
This commit is contained in:
parent
b5c45762c9
commit
3aad2a9f4a
@ -284,7 +284,7 @@ void fix_model_by_win10_sdk(const std::string &path_src, const std::string &path
|
|||||||
|
|
||||||
// Open the destination file.
|
// Open the destination file.
|
||||||
FILE *fout = boost::nowide::fopen(path_dst.c_str(), "wb");
|
FILE *fout = boost::nowide::fopen(path_dst.c_str(), "wb");
|
||||||
|
try {
|
||||||
Microsoft::WRL::ComPtr<ABI::Windows::Storage::Streams::IBuffer> buffer;
|
Microsoft::WRL::ComPtr<ABI::Windows::Storage::Streams::IBuffer> buffer;
|
||||||
byte *buffer_ptr;
|
byte *buffer_ptr;
|
||||||
bufferFactory->Create(65536 * 2048, buffer.GetAddressOf());
|
bufferFactory->Create(65536 * 2048, buffer.GetAddressOf());
|
||||||
@ -295,7 +295,6 @@ void fix_model_by_win10_sdk(const std::string &path_src, const std::string &path
|
|||||||
}
|
}
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
hr = buffer->get_Length(&length);
|
hr = buffer->get_Length(&length);
|
||||||
|
|
||||||
Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncOperationWithProgress<ABI::Windows::Storage::Streams::IBuffer*, UINT32>> asyncRead;
|
Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncOperationWithProgress<ABI::Windows::Storage::Streams::IBuffer*, UINT32>> asyncRead;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
hr = inputStream->ReadAsync(buffer.Get(), 65536 * 2048, ABI::Windows::Storage::Streams::InputStreamOptions_ReadAhead, asyncRead.GetAddressOf());
|
hr = inputStream->ReadAsync(buffer.Get(), 65536 * 2048, ABI::Windows::Storage::Streams::InputStreamOptions_ReadAhead, asyncRead.GetAddressOf());
|
||||||
@ -307,6 +306,10 @@ void fix_model_by_win10_sdk(const std::string &path_src, const std::string &path
|
|||||||
break;
|
break;
|
||||||
fwrite(buffer_ptr, length, 1, fout);
|
fwrite(buffer_ptr, length, 1, fout);
|
||||||
}
|
}
|
||||||
|
} catch (...) {
|
||||||
|
fclose(fout);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
fclose(fout);
|
fclose(fout);
|
||||||
// Here all the COM objects will be released through the ComPtr destructors.
|
// Here all the COM objects will be released through the ComPtr destructors.
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user