diff --git a/redo/windows/tab.c b/redo/windows/tab.c index 6dcc0e86..8cdd7bdb 100644 --- a/redo/windows/tab.c +++ b/redo/windows/tab.c @@ -130,7 +130,8 @@ static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *chi // see below hide = curpage(t); - page = newTabPage(child); + page = newTabPage(); + tabPageSetChild(page, child); uiControlSetParent(page, uiControl(t)); // and make it invisible at first; we show it later if needed uiControlHide(page); diff --git a/redo/windows/tabpage.c b/redo/windows/tabpage.c index 3c96af8d..9b327ab1 100644 --- a/redo/windows/tabpage.c +++ b/redo/windows/tabpage.c @@ -49,6 +49,9 @@ static void tabPageResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, (*(t->baseResize))(uiControl(t), x, y, width, height, d); + if (t->child == NULL) + return; + dchild = uiControlSizing(uiControl(t)); if (GetClientRect(t->hwnd, &r) == 0) @@ -90,7 +93,7 @@ static INT_PTR CALLBACK dlgproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar return FALSE; } -uiControl *newTabPage(uiControl *child) +uiControl *newTabPage(void) { struct tabPage *t; HRESULT hr; @@ -107,13 +110,7 @@ uiControl *newTabPage(uiControl *child) if (hr != S_OK) logHRESULT("error setting tab page background in newTabPage()", hr); - // needs to be done here, otherwise the uiControlSetParent() below will crash - // TODO split into separate functions uiControl(t)->Handle = tabPageHandle; - - t->child = child; - uiControlSetParent(t->child, uiControl(t)); - uiControl(t)->PreferredSize = tabPagePreferredSize; t->baseResize = uiControl(t)->Resize; uiControl(t)->Resize = tabPageResize; @@ -144,3 +141,12 @@ void tabPageDestroyChild(uiControl *c) uiControlDestroy(t->child); t->child = NULL; } + +void tabPageSetChild(uiControl *c, uiControl *child) +{ + struct tabPage *t = (struct tabPage *) c; + + t->child = child; + t->child = child; + uiControlSetParent(t->child, uiControl(t)); +} diff --git a/redo/windows/uipriv_windows.h b/redo/windows/uipriv_windows.h index 2e0281c4..cb8caf2c 100644 --- a/redo/windows/uipriv_windows.h +++ b/redo/windows/uipriv_windows.h @@ -115,7 +115,8 @@ extern void endDialogHelper(HWND); extern void setSingleHWNDFuncs(uiControl *); // tabpage.c -extern uiControl *newTabPage(uiControl *); +extern uiControl *newTabPage(void); extern int tabPageMargined(uiControl *); extern void tabPageSetMargined(uiControl *, int); extern void tabPageDestroyChild(uiControl *); +extern void tabPageSetChild(uiControl *, uiControl *);