Cleaned up the new control lifetime logic on Windows.
This commit is contained in:
parent
55fe50463f
commit
cf8871c524
|
@ -14,17 +14,17 @@ struct singleHWND {
|
||||||
BOOL containerHid;
|
BOOL containerHid;
|
||||||
BOOL userDisabled;
|
BOOL userDisabled;
|
||||||
BOOL containerDisabled;
|
BOOL containerDisabled;
|
||||||
BOOL canDestroy;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void singleDestroy(uiControl *c)
|
static void singleDestroy(uiControl *c)
|
||||||
{
|
{
|
||||||
singleHWND *s = (singleHWND *) (c->Internal);
|
singleHWND *s = (singleHWND *) (c->Internal);
|
||||||
|
|
||||||
s->canDestroy = TRUE;
|
SendMessageW(s->hwnd, msgCanDestroyNow, 0, 0);
|
||||||
|
(*(s->onDestroy))(s->onDestroyData);
|
||||||
if (DestroyWindow(s->hwnd) == 0)
|
if (DestroyWindow(s->hwnd) == 0)
|
||||||
logLastError("error destroying control in singleDestroy()");
|
logLastError("error destroying control in singleDestroy()");
|
||||||
// the data structures are destroyed in the subclass procedure
|
uiFree(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintptr_t singleHandle(uiControl *c)
|
static uintptr_t singleHandle(uiControl *c)
|
||||||
|
@ -164,12 +164,10 @@ static LRESULT CALLBACK singleSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
||||||
return lResult;
|
return lResult;
|
||||||
break;
|
break;
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
if (!s->canDestroy)
|
case WM_NCDESTROY: // just in case
|
||||||
complain("trying to destroy control with singleWidget at %p before uiControlDestroy()", s);
|
complain("trying to destroy control at %p before uiControlDestroy()", c);
|
||||||
(*(s->onDestroy))(s->onDestroyData);
|
|
||||||
uiFree(s);
|
|
||||||
break;
|
break;
|
||||||
case WM_NCDESTROY:
|
case msgCanDestroyNow:
|
||||||
if ((*fv_RemoveWindowSubclass)(hwnd, singleSubclassProc, uIdSubclass) == FALSE)
|
if ((*fv_RemoveWindowSubclass)(hwnd, singleSubclassProc, uIdSubclass) == FALSE)
|
||||||
logLastError("error removing Windows control subclass in singleSubclassProc()");
|
logLastError("error removing Windows control subclass in singleSubclassProc()");
|
||||||
break;
|
break;
|
||||||
|
@ -214,6 +212,7 @@ void uiWindowsNewControl(uiControl *c, uiWindowsNewControlParams *p)
|
||||||
if (p->useStandardControlFont)
|
if (p->useStandardControlFont)
|
||||||
SendMessageW(s->hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
|
SendMessageW(s->hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
|
||||||
|
|
||||||
|
// this handles both blocking control destruction and redirected notification messages
|
||||||
if ((*fv_SetWindowSubclass)(s->hwnd, singleSubclassProc, 0, (DWORD_PTR) c) == FALSE)
|
if ((*fv_SetWindowSubclass)(s->hwnd, singleSubclassProc, 0, (DWORD_PTR) c) == FALSE)
|
||||||
logLastError("error subclassing Windows control in uiWindowsNewControl()");
|
logLastError("error subclassing Windows control in uiWindowsNewControl()");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue