From 5a982d2102d67d6e0cf5665a91636b01d19e9fb2 Mon Sep 17 00:00:00 2001 From: Devin Lane Date: Mon, 7 Dec 2020 20:35:31 -0700 Subject: [PATCH] Fix a memory leak due to captured strong self and a retain cycle - Don't use `self` in a capturing block - Use `weak` for an unowned object --- DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderContext.m | 2 +- DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderProgram.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderContext.m b/DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderContext.m index 351d062..d8b6ff6 100644 --- a/DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderContext.m +++ b/DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderContext.m @@ -52,7 +52,7 @@ - (id)initWithMultiThreadSupport:(BOOL)multiThread; { usingBlock:^(NSNotification *notification) { __typeof__ (self) strongSelf = weakSelf; if (strongSelf) { - CVOpenGLESTextureCacheFlush([self coreVideoTextureCache], 0); + CVOpenGLESTextureCacheFlush([strongSelf coreVideoTextureCache], 0); } }]; diff --git a/DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderProgram.h b/DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderProgram.h index f8a3834..6dfb26f 100644 --- a/DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderProgram.h +++ b/DJIWidget/VideoPreviewer/Render/Base/DJILiveViewRenderProgram.h @@ -20,7 +20,7 @@ @property(readwrite, nonatomic) BOOL initialized; @property(readonly, nonatomic) BOOL released; -@property(readonly, nonatomic) DJILiveViewRenderContext* context; +@property(weak, readonly, nonatomic) DJILiveViewRenderContext* context; @property(readwrite, copy, nonatomic) NSString *vertexShaderLog; @property(readwrite, copy, nonatomic) NSString *fragmentShaderLog; @property(readwrite, copy, nonatomic) NSString *programLog;