]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed memory leak in wxNativeFontInfo when using Pango
authorVáclav Slavík <vslavik@fastmail.fm>
Fri, 2 Jul 2004 20:54:12 +0000 (20:54 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Fri, 2 Jul 2004 20:54:12 +0000 (20:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28146 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/fontutil.h
src/gtk/control.cpp
src/gtk/settings.cpp
src/gtk1/control.cpp
src/gtk1/settings.cpp
src/unix/fontutil.cpp

index 2e25a581c671b805a53ea53716a21329950c5e36..e2243613dce52c980b8755ab45d90d5751b3dceb 100644 (file)
@@ -135,6 +135,11 @@ public:
     // default ctor (default copy ctor is ok)
     wxNativeFontInfo() { Init(); }
 
+#if wxUSE_PANGO
+    wxNativeFontInfo(const wxNativeFontInfo& info);
+    ~wxNativeFontInfo();
+#endif
+
     // reset to the default state
     void Init();
 
index f8ea0c9dc335709e6d3f88b020528f65b7eb248b..5adb0823c6ce5e15253bf8314300bfa37ebddc26 100644 (file)
@@ -204,7 +204,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
     if ( style && style->font_desc )
     {  
         wxNativeFontInfo info;  
-        info.description = style->font_desc;  
+        info.description = pango_font_description_copy(style->font_desc);
         attr.font = wxFont(info);  
     }  
     else  
index 29c639b59010e6fceb12617627ee3defe9113eb8..99a09be81e00e29e858364f5b125506c836c4386 100644 (file)
@@ -308,7 +308,8 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
                 if ( def && def->font_desc )
                 {  
                     wxNativeFontInfo info;  
-                    info.description = def->font_desc;  
+                    info.description = 
+                        pango_font_description_copy(def->font_desc);
                     gs_objects.m_fontSystem = wxFont(info);  
                 }  
                 else  
index f8ea0c9dc335709e6d3f88b020528f65b7eb248b..5adb0823c6ce5e15253bf8314300bfa37ebddc26 100644 (file)
@@ -204,7 +204,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
     if ( style && style->font_desc )
     {  
         wxNativeFontInfo info;  
-        info.description = style->font_desc;  
+        info.description = pango_font_description_copy(style->font_desc);
         attr.font = wxFont(info);  
     }  
     else  
index 29c639b59010e6fceb12617627ee3defe9113eb8..99a09be81e00e29e858364f5b125506c836c4386 100644 (file)
@@ -308,7 +308,8 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
                 if ( def && def->font_desc )
                 {  
                     wxNativeFontInfo info;  
-                    info.description = def->font_desc;  
+                    info.description = 
+                        pango_font_description_copy(def->font_desc);
                     gs_objects.m_fontSystem = wxFont(info);  
                 }  
                 else  
index 09c673e0c225ac4bf17f4544698c6cfc4fef3d4b..79f36b31dda4c5d712a2f463931073eee97ceb30 100644 (file)
@@ -57,6 +57,20 @@ void wxNativeFontInfo::Init()
     description = NULL;
 }
 
+wxNativeFontInfo::wxNativeFontInfo(const wxNativeFontInfo& info)
+{
+    if (info.description)
+        description = pango_font_description_copy(info.description);
+    else
+        description = NULL;            
+}
+
+wxNativeFontInfo::~wxNativeFontInfo()
+{
+    if (description)
+        pango_font_description_free(description);
+}
+
 int wxNativeFontInfo::GetPointSize() const
 {
     return pango_font_description_get_size( description ) / PANGO_SCALE;