From 8709838a8f409919c5008d9a0bd1b7b726f661b1 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 17 Mar 2018 23:07:40 -0400 Subject: [PATCH] Added a uiFreeFontButtonFont() function to free resources allocated by uiFontButtonFont(), implemented it on Windows, and integrated it into the drawtext example. I'm going to continue chipping away at the Windows code for a bit longer, so I'll add this to the other platforms later. --- examples/drawtext/main.c | 1 + ui_attrstr.h | 1 + windows/fontbutton.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/examples/drawtext/main.c b/examples/drawtext/main.c index 98d206f9..615340e7 100644 --- a/examples/drawtext/main.c +++ b/examples/drawtext/main.c @@ -106,6 +106,7 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p) // TODO clip to margins uiDrawText(p->Context, textLayout, margins, margins); uiDrawFreeTextLayout(textLayout); + uiFreeFontButtonFont(&defaultFont); } static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e) diff --git a/ui_attrstr.h b/ui_attrstr.h index f4302cd5..3486b4e9 100644 --- a/ui_attrstr.h +++ b/ui_attrstr.h @@ -495,3 +495,4 @@ _UI_EXTERN void uiFontButtonFont(uiFontButton *b, uiFontDescriptor *desc); // TOOD SetFont, mechanics _UI_EXTERN void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data); _UI_EXTERN uiFontButton *uiNewFontButton(void); +_UI_EXTERN void uiFreeFontButtonFont(uiFontDescriptor *desc); diff --git a/windows/fontbutton.cpp b/windows/fontbutton.cpp index 29de64b6..d6e5e0d8 100644 --- a/windows/fontbutton.cpp +++ b/windows/fontbutton.cpp @@ -121,3 +121,8 @@ uiFontButton *uiNewFontButton(void) return b; } + +void uiFreeFontButtonFont(uiFontDescriptor *desc) +{ + uiprivFree((char *) (desc->Family)); +}