From a892e6b339c5f34a1eef696f5cb3a378c0b150cc Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 1 Jun 2015 18:06:15 -0400 Subject: [PATCH] Handled memory destruction for uiRadioButtons properly. --- redo/windows/radiobuttons.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/redo/windows/radiobuttons.c b/redo/windows/radiobuttons.c index ac93fd56..4d4fd4ea 100644 --- a/redo/windows/radiobuttons.c +++ b/redo/windows/radiobuttons.c @@ -33,7 +33,16 @@ static BOOL onWM_COMMAND(uiControl *c, HWND clicked, WORD code, LRESULT *lResult static void radiobuttonsCommitDestroy(uiControl *c) { - // TODO + struct radiobuttons *r = (struct radiobuttons *) c; + HWND hwnd; + + while (r->hwnds->len != 0) { + hwnd = ptrArrayIndex(r->hwnds, HWND, 0); + ptrArrayDelete(r->hwnds, 0); + uiWindowsUnregisterWM_COMMANDHandler(hwnd); + uiWindowsUtilDestroy(hwnd); + } + ptrArrayDestroy(r->hwnds); } // radio buttons have more than one handle @@ -148,6 +157,7 @@ static void radiobuttonsAppend(uiRadioButtons *rr, const char *text) BS_RADIOBUTTON | WS_TABSTOP | WS_CHILD | WS_VISIBLE, hInstance, NULL, TRUE); + uiFree(wtext); uiWindowsUtilSetParent(hwnd, r->parent); uiWindowsRegisterWM_COMMANDHandler(hwnd, onWM_COMMAND, uiControl(r)); ptrArrayAppend(r->hwnds, hwnd);