mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-03-23 18:54:01 +08:00
Fix memory leaks reported by Xcode Memory Analysis
Mostly just add autorelease to avoid various objects being leaked, but also add manual calls to release for the code which is not necessarily executed inside a GUI application and so can't rely on autorelease pool existence.
This commit is contained in:
committed by
Vadim Zeitlin
parent
b581980bef
commit
985a64f11d
@@ -2019,7 +2019,7 @@ void wxCocoaDataViewControl::InitOutlineView(long style)
|
||||
NSTableHeaderView* header = nil;
|
||||
if ( !(style & wxDV_NO_HEADER) )
|
||||
{
|
||||
header = [[wxDVCNSHeaderView alloc] initWithDVC:GetDataViewCtrl()];
|
||||
header = [[[wxDVCNSHeaderView alloc] initWithDVC:GetDataViewCtrl()] autorelease];
|
||||
}
|
||||
|
||||
[m_OutlineView setHeaderView:header];
|
||||
|
||||
@@ -86,7 +86,7 @@ wxWidgetImplType* wxWidgetImpl::CreateGroupBox( wxWindowMac* wxpeer,
|
||||
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
||||
wxNSBox* v = [[wxNSBox alloc] initWithFrame:r];
|
||||
NSSize margin = { 0.0, 0.0 };
|
||||
[v setContentView:[[wxNSBoxContentView alloc] init]];
|
||||
[v setContentView:[[[wxNSBoxContentView alloc] init] autorelease]];
|
||||
[v setContentViewMargins: margin];
|
||||
[v sizeToFit];
|
||||
wxStaticBoxCocoaImpl* c = new wxStaticBoxCocoaImpl( wxpeer, v );
|
||||
|
||||
@@ -303,7 +303,9 @@ wxUILocaleImplCF::GetMonthName(wxDateTime::Month month, wxDateTime::NameForm for
|
||||
}
|
||||
|
||||
NSString* monthName = [monthNames objectAtIndex:(month)];
|
||||
return wxCFStringRef::AsString(monthName);
|
||||
wxCFStringRef cf(monthName);
|
||||
[df release];
|
||||
return cf.AsString();
|
||||
}
|
||||
|
||||
wxString
|
||||
@@ -348,7 +350,9 @@ wxUILocaleImplCF::GetWeekDayName(wxDateTime::WeekDay weekday, wxDateTime::NameFo
|
||||
}
|
||||
|
||||
NSString* weekdayName = [weekdayNames objectAtIndex:(weekday)];
|
||||
return wxCFStringRef::AsString(weekdayName);
|
||||
wxCFStringRef cf(weekdayName);
|
||||
[df release];
|
||||
return cf.AsString();
|
||||
}
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
|
||||
{
|
||||
for (const auto& kv : m_handlers)
|
||||
{
|
||||
[webViewConfig setURLSchemeHandler:[[WebViewCustomProtocol alloc] initWithHandler:kv.second.get()]
|
||||
[webViewConfig setURLSchemeHandler:[[[WebViewCustomProtocol alloc] initWithHandler:kv.second.get()] autorelease]
|
||||
forURLScheme:wxCFStringRef(kv.first).AsNSString()];
|
||||
}
|
||||
}
|
||||
@@ -334,7 +334,7 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
|
||||
document.webkitFullscreenEnabled = true; \
|
||||
");
|
||||
[m_webView.configuration.userContentController addScriptMessageHandler:
|
||||
[[WebViewScriptMessageHandler alloc] initWithWxWindow:this] name:@"__wxfullscreen"];
|
||||
[[[WebViewScriptMessageHandler alloc] initWithWxWindow:this]autorelease] name:@"__wxfullscreen"];
|
||||
}
|
||||
|
||||
m_UIDelegate = uiDelegate;
|
||||
@@ -620,7 +620,7 @@ void wxWebViewWebKit::RunScriptAsync(const wxString& javascript, void* clientDat
|
||||
bool wxWebViewWebKit::AddScriptMessageHandler(const wxString& name)
|
||||
{
|
||||
[m_webView.configuration.userContentController addScriptMessageHandler:
|
||||
[[WebViewScriptMessageHandler alloc] initWithWxWindow:this] name:wxCFStringRef(name).AsNSString()];
|
||||
[[[WebViewScriptMessageHandler alloc] initWithWxWindow:this] autorelease] name:wxCFStringRef(name).AsNSString()];
|
||||
// Make webkit message handler available under common name
|
||||
wxString js = wxString::Format("window.%s = window.webkit.messageHandlers.%s;",
|
||||
name, name);
|
||||
@@ -644,6 +644,7 @@ bool wxWebViewWebKit::AddUserScript(const wxString& javascript,
|
||||
WKUserScriptInjectionTimeAtDocumentStart : WKUserScriptInjectionTimeAtDocumentEnd
|
||||
forMainFrameOnly:NO];
|
||||
[m_webView.configuration.userContentController addUserScript:userScript];
|
||||
[userScript release];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ WX_NSWindow CreateFloatingWindow(wxWindow* wxWin)
|
||||
defer: NO];
|
||||
[w setLevel:NSPopUpMenuWindowLevel];
|
||||
[w setHasShadow:YES];
|
||||
[w setContentView:[[wxSTCPopupBaseView alloc] initWithwxWin:wxWin]];
|
||||
[w setContentView:[[[wxSTCPopupBaseView alloc] initWithwxWin:wxWin] autorelease]] ;
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user