From 40dee5a693773eacf0320edd81f6e67532b15a61 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 30 Apr 2015 17:49:38 -0400 Subject: [PATCH] Added bin destruction OS parent checks. --- darwin/bin.m | 1 + unix/bin.c | 5 +++++ windows/bin.c | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/darwin/bin.m b/darwin/bin.m index a139c1e0..a1c6a978 100644 --- a/darwin/bin.m +++ b/darwin/bin.m @@ -16,6 +16,7 @@ void binDestroy(uiControl *c) struct bin *b = (struct bin *) c; // TODO find a way to move the parented check here + // we can't check for an OS parent here because what we're working with with bin isn't subviews but rather content views (at least I think... TODO) // don't chain up to base here; we need to destroy children ourselves first if (b->mainControl != NULL) { uiControlSetParent(b->mainControl, NULL); diff --git a/unix/bin.c b/unix/bin.c index 6773d629..90a4d016 100644 --- a/unix/bin.c +++ b/unix/bin.c @@ -17,8 +17,13 @@ struct bin { void binDestroy(uiControl *c) { struct bin *b = (struct bin *) c; + GtkWidget *binWidget; // TODO find a way to move the parented check here + // ensure clean removal by making sure the bin has no OS parent + binWidget = GTK_WIDGET(uiControlHandle(uiControl(b))); + if (gtk_widget_get_parent(binWidget) != NULL) + complain("attempt to destroy bin %p while it has an OS parent", b); // don't chain up to base here; we need to destroy children ourselves first if (b->mainControl != NULL) { uiControlSetParent(b->mainControl, NULL); diff --git a/windows/bin.c b/windows/bin.c index 3a59715b..66c2fb1f 100644 --- a/windows/bin.c +++ b/windows/bin.c @@ -14,8 +14,13 @@ struct bin { void binDestroy(uiControl *c) { struct bin *b = (struct bin *) c; + HWND hwnd; // TODO find a way to move the parented check here + // ensure clean removal by making sure the bin has no OS parent + hwnd = (HWND) uiControlHandle(uiControl(b)); + if (GetAncestor(hwnd, GA_PARENT) != NULL) + complain("attempt to destroy bin %p while it has an OS parent", b); // don't chain up to base here; we need to destroy children ourselves first if (b->mainControl != NULL) { uiControlSetParent(b->mainControl, NULL);