summaryrefslogtreecommitdiff
path: root/new/container_unix.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-08 17:06:23 -0400
committerPietro Gagliardi <[email protected]>2015-04-08 17:08:25 -0400
commitec070204a55be1c3f046cdc1896225a6cddf1b2f (patch)
tree5575c543b107d3c61d818a97ebcda7ce697679de /new/container_unix.c
parenta97c9297c306f5796c00812edb6e018cbdc52b8b (diff)
More TODO resolving. More TODOs.
Diffstat (limited to 'new/container_unix.c')
-rw-r--r--new/container_unix.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/new/container_unix.c b/new/container_unix.c
index f5cd056..047b40a 100644
--- a/new/container_unix.c
+++ b/new/container_unix.c
@@ -12,18 +12,25 @@ static void uiContainer_init(uiContainer *c)
gtk_widget_set_has_window(GTK_WIDGET(c), FALSE);
}
-// TODO explain the order here
-// TODO guard against use of forall after the ptr array unref
+// instead of having GtkContainer itself unref all our controls, we'll run our own uiControlDestroy() functions for child, which will do that and more
+// we still chain up because we need to, but by that point there will be no children for GtkContainer to free
static void uiContainer_dispose(GObject *obj)
{
- g_ptr_array_unref(uiContainer(obj)->children);
- if (uiContainer(obj)->child != NULL) {
- uiControlDestroy(uiContainer(obj)->child);
- uiContainer(obj)->child = NULL;
+ uiContainer *c = uiContainer(obj);
+
+ if (c->children != NULL) {
+ g_ptr_array_unref(c->children);
+ c->children = NULL;
+ }
+ if (c->child != NULL) {
+ uiControlDestroy(c->child);
+ c->child = NULL;
}
G_OBJECT_CLASS(uiContainer_parent_class)->dispose(obj);
}
+// TODO switch from using uiContainer() directly below
+
static void uiContainer_finalize(GObject *obj)
{
G_OBJECT_CLASS(uiContainer_parent_class)->finalize(obj);
@@ -35,13 +42,15 @@ static void uiContainer_finalize(GObject *obj)
static void uiContainer_add(GtkContainer *container, GtkWidget *widget)
{
gtk_widget_set_parent(widget, GTK_WIDGET(container));
- g_ptr_array_add(uiContainer(container)->children, widget);
+ if (uiContainer(container)->children != NULL)
+ g_ptr_array_add(uiContainer(container)->children, widget);
}
static void uiContainer_remove(GtkContainer *container, GtkWidget *widget)
{
gtk_widget_unparent(widget);
- g_ptr_array_remove(uiContainer(container)->children, widget);
+ if (uiContainer(container)->children != NULL)
+ g_ptr_array_remove(uiContainer(container)->children, widget);
}
static void uiContainer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
@@ -73,7 +82,8 @@ static void uiContainer_forall(GtkContainer *container, gboolean includeInternal
s.callback = callback;
s.data = data;
- g_ptr_array_foreach(uiContainer(container)->children, doforall, &s);
+ if (uiContainer(container)->children != NULL)
+ g_ptr_array_foreach(uiContainer(container)->children, doforall, &s);
}
static void uiContainer_class_init(uiContainerClass *class)