From 557b8526d166f7785d71939bde03f346f467d430 Mon Sep 17 00:00:00 2001 From: "Konstantin S. Matveyev" Date: Sat, 19 Jan 2019 18:06:08 +0300 Subject: [PATCH] Fix several problems with wxAppProgressIndicator in wxOSX Don't release NSProgressIndicator too soon, we need to be able to keep it to use it later, so move "release" from wxAppProgressDockIcon ctor to its dtor. OTOH, remove an extraneous "retain" to fix memory leak of wxAppProgressDockIcon. Finally, show the indicator, if it had been hidden, when Pulse() is called for consistency with SetProgress(). Closes https://github.com/wxWidgets/wxWidgets/pull/1150 --- src/osx/cocoa/appprogress.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/osx/cocoa/appprogress.mm b/src/osx/cocoa/appprogress.mm index 892bb89ef5..350190e136 100644 --- a/src/osx/cocoa/appprogress.mm +++ b/src/osx/cocoa/appprogress.mm @@ -42,15 +42,21 @@ [m_progIndicator setBezeled:YES]; [m_progIndicator setMinValue:0]; [m_progIndicator setMaxValue:1]; - [m_progIndicator release]; [self setProgress:0.0]; } return self; } +- (void)dealloc +{ + [m_progIndicator release]; + [super dealloc]; +} + - (void)setProgress: (double)value { [m_progIndicator setHidden:NO]; + [m_progIndicator setIndeterminate:NO]; [m_progIndicator setDoubleValue:value]; [m_dockTile display]; @@ -58,6 +64,7 @@ - (void)setIndeterminate: (bool)indeterminate { + [m_progIndicator setHidden:NO]; [m_progIndicator setIndeterminate:indeterminate]; [m_dockTile display]; @@ -75,7 +82,7 @@ wxAppProgressIndicator::wxAppProgressIndicator(wxWindow* WXUNUSED(parent), int maxValue ): m_maxValue(maxValue) { - wxAppProgressDockIcon* dockIcon = [[[wxAppProgressDockIcon alloc] init] retain]; + wxAppProgressDockIcon* dockIcon = [[wxAppProgressDockIcon alloc] init]; m_dockIcon = dockIcon; }