From ac774b4e3b2a6ff325e6794d9957e4c5471bc12a Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 8 Mar 2016 00:38:06 -0600 Subject: [PATCH] Fixed a memory corruption issue, where AddImage was being called multiple times (at the same time). Added a lock, and I can no longer reproduce the crash. --- include/Frame.h | 1 + src/Frame.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/Frame.h b/include/Frame.h index 6d80577a..ee1db47e 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -119,6 +119,7 @@ namespace openshot tr1::shared_ptr wave_image; tr1::shared_ptr audio; tr1::shared_ptr previewApp; + CriticalSection addingImageSection; const unsigned char *qbuffer; Fraction pixel_ratio; int channels; diff --git a/src/Frame.cpp b/src/Frame.cpp index 226cb731..7d0dc2db 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -676,6 +676,7 @@ void Frame::AddColor(int width, int height, string color) void Frame::AddImage(int width, int height, int bytes_per_pixel, QImage::Format type, const unsigned char *pixels_) { // Create new buffer + const GenericScopedLock lock(addingImageSection); int buffer_size = width * height * bytes_per_pixel; qbuffer = new unsigned char[buffer_size]();