Started the work to settle lifetime issues on the Windows backend.
This commit is contained in:
parent
0a1e9b5f13
commit
8dcdbd0878
2
uipriv.h
2
uipriv.h
|
@ -8,3 +8,5 @@ extern void *uiAlloc(size_t, const char *);
|
|||
#define uiNew(T) ((T *) uiAlloc(sizeof (T), #T ))
|
||||
extern void *uiRealloc(void *, size_t, const char *);
|
||||
extern void uiFree(void *);
|
||||
|
||||
extern void complain(const char *, ...);
|
||||
|
|
|
@ -13,12 +13,14 @@ struct singleHWND {
|
|||
BOOL containerHid;
|
||||
BOOL userDisabled;
|
||||
BOOL containerDisabled;
|
||||
BOOL canDestroy;
|
||||
};
|
||||
|
||||
static void singleDestroy(uiControl *c)
|
||||
{
|
||||
singleHWND *s = (singleHWND *) (c->Internal);
|
||||
|
||||
s->canDestroy = TRUE;
|
||||
if (DestroyWindow(s->hwnd) == 0)
|
||||
logLastError("error destroying control in singleDestroy()");
|
||||
// the data structures are destroyed in the subclass procedure
|
||||
|
@ -161,6 +163,8 @@ static LRESULT CALLBACK singleSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||
return lResult;
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
if (!s->canDestroy)
|
||||
complain("trying to destroy control with singleWidget at %p before uiControlDestroy()", s);
|
||||
(*(s->onWM_DESTROY))(c);
|
||||
uiFree(s);
|
||||
break;
|
||||
|
|
|
@ -71,3 +71,13 @@ int windowClassOf(HWND hwnd, ...)
|
|||
va_end(ap);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void complain(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
abort();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue