Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Bubnik <bubnikv@gmail.com>2022-01-04 19:29:17 +0300
committerVojtech Bubnik <bubnikv@gmail.com>2022-01-04 19:29:24 +0300
commit3aad2a9f4aacaa32f1f3bfed0ed26ce7ae5ac47a (patch)
tree77356755c5273db597f1f9c2f2cf835e56aa3631 /src/slic3r
parentb5c45762c9c0aef7b849edfeb7d548ff40b03b4b (diff)
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
Diffstat (limited to 'src/slic3r')
-rw-r--r--src/slic3r/Utils/FixModelByWin10.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/slic3r/Utils/FixModelByWin10.cpp b/src/slic3r/Utils/FixModelByWin10.cpp
index 6f6b21f68..296c58622 100644
--- a/src/slic3r/Utils/FixModelByWin10.cpp
+++ b/src/slic3r/Utils/FixModelByWin10.cpp
@@ -284,29 +284,32 @@ void fix_model_by_win10_sdk(const std::string &path_src, const std::string &path
// Open the destination file.
FILE *fout = boost::nowide::fopen(path_dst.c_str(), "wb");
-
- Microsoft::WRL::ComPtr<ABI::Windows::Storage::Streams::IBuffer> buffer;
- byte *buffer_ptr;
- bufferFactory->Create(65536 * 2048, buffer.GetAddressOf());
- {
- Microsoft::WRL::ComPtr<Windows::Storage::Streams::IBufferByteAccess> bufferByteAccess;
- buffer.As(&bufferByteAccess);
- hr = bufferByteAccess->Buffer(&buffer_ptr);
- }
- uint32_t length;
- hr = buffer->get_Length(&length);
-
- Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncOperationWithProgress<ABI::Windows::Storage::Streams::IBuffer*, UINT32>> asyncRead;
- for (;;) {
- hr = inputStream->ReadAsync(buffer.Get(), 65536 * 2048, ABI::Windows::Storage::Streams::InputStreamOptions_ReadAhead, asyncRead.GetAddressOf());
- status = winrt_async_await(asyncRead, throw_on_cancel);
- if (status != AsyncStatus::Completed)
- throw Slic3r::RuntimeError(L("Saving mesh into the 3MF container failed."));
+ try {
+ Microsoft::WRL::ComPtr<ABI::Windows::Storage::Streams::IBuffer> buffer;
+ byte *buffer_ptr;
+ bufferFactory->Create(65536 * 2048, buffer.GetAddressOf());
+ {
+ Microsoft::WRL::ComPtr<Windows::Storage::Streams::IBufferByteAccess> bufferByteAccess;
+ buffer.As(&bufferByteAccess);
+ hr = bufferByteAccess->Buffer(&buffer_ptr);
+ }
+ uint32_t length;
hr = buffer->get_Length(&length);
- if (length == 0)
- break;
- fwrite(buffer_ptr, length, 1, fout);
- }
+ Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncOperationWithProgress<ABI::Windows::Storage::Streams::IBuffer*, UINT32>> asyncRead;
+ for (;;) {
+ hr = inputStream->ReadAsync(buffer.Get(), 65536 * 2048, ABI::Windows::Storage::Streams::InputStreamOptions_ReadAhead, asyncRead.GetAddressOf());
+ status = winrt_async_await(asyncRead, throw_on_cancel);
+ if (status != AsyncStatus::Completed)
+ throw Slic3r::RuntimeError(L("Saving mesh into the 3MF container failed."));
+ hr = buffer->get_Length(&length);
+ if (length == 0)
+ break;
+ fwrite(buffer_ptr, length, 1, fout);
+ }
+ } catch (...) {
+ fclose(fout);
+ throw;
+ }
fclose(fout);
// Here all the COM objects will be released through the ComPtr destructors.
}