From 47723aa8d9605a09ee119dfc14fda4148413cc20 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 8 Apr 2015 20:14:10 -0400 Subject: [PATCH] More TODO resolution. --- new/container_windows.c | 3 +++ new/uipriv.h | 2 +- new/uipriv_windows.h | 12 +++++------- new/util_windows.c | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/new/container_windows.c b/new/container_windows.c index 20d7d8d..d56830e 100644 --- a/new/container_windows.c +++ b/new/container_windows.c @@ -63,6 +63,9 @@ void resize(uiControl *control, HWND parent, RECT r) TEXTMETRICW tm; SIZE size; + size.cx = 0; + size.cy = 0; + ZeroMemory(&tm, sizeof (TEXTMETRICW)); dc = GetDC(parent); if (dc == NULL) logLastError("error getting DC in resize()"); diff --git a/new/uipriv.h b/new/uipriv.h index a12fbdc..0521bf6 100644 --- a/new/uipriv.h +++ b/new/uipriv.h @@ -18,7 +18,7 @@ struct uiControl { void (*resize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *); }; -// TODO write this comment +// uncomment the following line to enable memory logging; see leaks.awk #define uiLogAllocations extern void *uiAlloc(size_t, const char *); diff --git a/new/uipriv_windows.h b/new/uipriv_windows.h index f12a6b6..bc8890a 100644 --- a/new/uipriv_windows.h +++ b/new/uipriv_windows.h @@ -35,13 +35,6 @@ enum { msgNOTIFY, }; -// TODO move this to the right place -struct uiSizing { - int baseX; - int baseY; - LONG internalLeading; -}; - // debug_windows.c extern HRESULT logLastError(const char *); extern HRESULT logHRESULT(const char *, HRESULT); @@ -58,6 +51,11 @@ extern WCHAR *toUTF16(const char *); // container_windows.c extern BOOL sharedWndProc(HWND, UINT, WPARAM, LPARAM, LRESULT *); +struct uiSizing { + int baseX; + int baseY; + LONG internalLeading; +}; extern void resize(uiControl *, HWND, RECT); // comctl32_windows.c diff --git a/new/util_windows.c b/new/util_windows.c index 4f883b9..5034dae 100644 --- a/new/util_windows.c +++ b/new/util_windows.c @@ -17,7 +17,6 @@ WCHAR *toUTF16(const char *str) return wstr; } -// TODO this and resize(): initialize size and other values to avoid garbage on failure intmax_t uiWindowsWindowTextWidth(HWND hwnd) { int len; @@ -26,6 +25,8 @@ intmax_t uiWindowsWindowTextWidth(HWND hwnd) HFONT prevfont; SIZE size; + size.cx = 0; + size.cy = 0; // TODO check for error len = GetWindowTextLengthW(hwnd); if (len == 0) // no text; nothing to do