Fixing Memory Leaking CTFontDescriptor Bug

see https://trac.wxwidgets.org/ticket/19012
This commit is contained in:
Stefan Csomor
2020-12-15 08:01:27 +01:00
parent 9bbaab6e56
commit 8fa54ec09a

View File

@@ -779,7 +779,8 @@ void wxNativeFontInfo::InitFromFont(CTFontRef font)
{
Init();
InitFromFontDescriptor(CTFontCopyFontDescriptor(font) );
wxCFRef<CTFontDescriptorRef> desc(CTFontCopyFontDescriptor(font));
InitFromFontDescriptor( desc );
}
void wxNativeFontInfo::InitFromFontDescriptor(CTFontDescriptorRef desc)
@@ -787,6 +788,7 @@ void wxNativeFontInfo::InitFromFontDescriptor(CTFontDescriptorRef desc)
Init();
m_descriptor.reset(wxCFRetain(desc));
int count = CFGetRetainCount(desc);
m_ctWeight = GetCTWeight(desc);
m_ctWidth = GetCTwidth(desc);
@@ -1065,6 +1067,7 @@ bool wxNativeFontInfo::FromString(const wxString& s)
if (descriptor != NULL)
{
InitFromFontDescriptor(descriptor);
CFRelease(descriptor);
m_underlined = underlined;
m_strikethrough = strikethrough;
m_encoding = encoding;