diff --git a/uipriv.h b/uipriv.h index 7cc17956..0d925de6 100644 --- a/uipriv.h +++ b/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 *, ...); diff --git a/windows/newcontrol.c b/windows/newcontrol.c index 565ec052..059a34db 100644 --- a/windows/newcontrol.c +++ b/windows/newcontrol.c @@ -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; diff --git a/windows/util.c b/windows/util.c index 93b32d8f..63529e59 100644 --- a/windows/util.c +++ b/windows/util.c @@ -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(); +}