From fdf7514a009227ebf09cf8e184b3d96aa33eb026 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 2 Jul 2004 20:54:12 +0000 Subject: [PATCH] fixed memory leak in wxNativeFontInfo when using Pango git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28146 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/fontutil.h | 5 +++++ src/gtk/control.cpp | 2 +- src/gtk/settings.cpp | 3 ++- src/gtk1/control.cpp | 2 +- src/gtk1/settings.cpp | 3 ++- src/unix/fontutil.cpp | 14 ++++++++++++++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/wx/fontutil.h b/include/wx/fontutil.h index 2e25a581c6..e2243613dc 100644 --- a/include/wx/fontutil.h +++ b/include/wx/fontutil.h @@ -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(); diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index f8ea0c9dc3..5adb0823c6 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -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 diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index 29c639b590..99a09be81e 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -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 diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index f8ea0c9dc3..5adb0823c6 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -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 diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index 29c639b590..99a09be81e 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -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 diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index 09c673e0c2..79f36b31dd 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -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; -- 2.47.2