From 6fd21e1655c2c21679fa773925bf155de395e6d0 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 18 Aug 2009 15:54:36 +0000 Subject: [PATCH] support for plug-in unloading, closes #10836 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61701 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/button.cpp | 11 +++++++++-- src/osx/carbon/stattext.cpp | 13 ++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/osx/carbon/button.cpp b/src/osx/carbon/button.cpp index 956ca32257..b2f0567d2b 100644 --- a/src/osx/carbon/button.cpp +++ b/src/osx/carbon/button.cpp @@ -66,14 +66,21 @@ wxSize wxButton::DoGetBestSize() const OSStatus err = m_peer->GetData( kControlEntireControl, kControlFontStyleTag, &controlFont ); verify_noerr( err ); - wxCFStringRef str( m_label, GetFont().GetEncoding() ); + // GetThemeTextDimensions will cache strings and the documentation + // says not to use the NoCopy string creation calls. + // This also means that we can't use CFSTR without + // -fno-constant-cfstrings if the library might be unloaded, + // as GetThemeTextDimensions may cache a pointer to our + // unloaded segment. + wxCFStringRef str( !m_label.empty() ? m_label : wxString(" "), + GetFont().GetEncoding() ); #if wxOSX_USE_ATSU_TEXT SInt16 baseline; if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont ) { err = GetThemeTextDimensions( - (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")), + (CFStringRef)str, m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline ); verify_noerr( err ); } diff --git a/src/osx/carbon/stattext.cpp b/src/osx/carbon/stattext.cpp index 14b10a3812..e51b2af2b1 100644 --- a/src/osx/carbon/stattext.cpp +++ b/src/osx/carbon/stattext.cpp @@ -65,14 +65,21 @@ wxSize wxStaticText::DoGetBestSize() const OSStatus err = m_peer->GetData( kControlEntireControl, kControlFontStyleTag, &controlFont ); verify_noerr( err ); - wxCFStringRef str( m_label, GetFont().GetEncoding() ); - #if wxOSX_USE_ATSU_TEXT SInt16 baseline; if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont ) { + // GetThemeTextDimensions will cache strings and the documentation + // says not to use the NoCopy string creation calls. + // This also means that we can't use CFSTR without + // -fno-constant-cfstrings if the library might be unloaded, + // as GetThemeTextDimensions may cache a pointer to our + // unloaded segment. + wxCFStringRef str( !m_label.empty() ? m_label : wxString(" "), + GetFont().GetEncoding() ); + err = GetThemeTextDimensions( - (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")), + (CFStringRef)str, m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline ); verify_noerr( err ); } -- 2.47.2