[goffice] Canvas: fix realize problems.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [goffice] Canvas: fix realize problems.
- Date: Wed, 16 Sep 2009 15:27:39 +0000 (UTC)
commit 1087afd66d26fe23ceae7ff1b73cfc3678080de7
Author: Morten Welinder <terra gnome org>
Date: Wed Sep 16 11:27:24 2009 -0400
Canvas: fix realize problems.
ChangeLog | 8 ++++++++
NEWS | 6 ++++++
goffice/canvas/goc-group.c | 16 ++--------------
goffice/canvas/goc-item.c | 44 ++++++++++++++++++++++++++++++++------------
4 files changed, 48 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 054157d..83035b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2009-09-16 Morten Welinder <terra gnome org>
+ * goffice/canvas/goc-item.c (goc_item_realize,
+ goc_item_unrealize): New handlers.
+ (_goc_item_realize, _goc_item_unrealize): Simplify.
+ (goc_item_new): Simplify and avoid double-realize.
+
+ * goffice/canvas/goc-group.c (goc_group_realize,
+ goc_group_unrealize): Simplify.
+
* goffice/canvas/goc-polygon.c (goc_polygon_finalize): New
function to plug leak.
diff --git a/NEWS b/NEWS
index 0032ecb..0db12f3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
goffice 0.7.13:
+Jean:
+ * Fix various problems with new canvas.
+
+Morten:
+ * Fix various problems with new canvas.
+
--------------------------------------------------------------------------
goffice 0.7.12:
diff --git a/goffice/canvas/goc-group.c b/goffice/canvas/goc-group.c
index 6a45c02..d3eaf31 100644
--- a/goffice/canvas/goc-group.c
+++ b/goffice/canvas/goc-group.c
@@ -176,15 +176,9 @@ goc_group_realize (GocItem *item)
{
GocGroup *group = GOC_GROUP (item);
GList *l;
- GocItemClass *klass;
for (l = g_list_first (group->children); l; l = g_list_next (l)) {
GocItem *child = GOC_ITEM (l->data);
- if (!child->realized) {
- klass = GOC_ITEM_GET_CLASS (child);
- if (klass->realize)
- klass->realize (child);
- child->realized = TRUE;
- }
+ _goc_item_realize (child);
}
}
@@ -193,15 +187,9 @@ goc_group_unrealize (GocItem *item)
{
GocGroup *group = GOC_GROUP (item);
GList *l;
- GocItemClass *klass;
for (l = g_list_first (group->children); l; l = g_list_next (l)) {
GocItem *child = GOC_ITEM (l->data);
- if (child->realized) {
- klass = GOC_ITEM_GET_CLASS (child);
- if (klass->unrealize)
- klass->unrealize (child);
- child->realized = FALSE;
- }
+ _goc_item_unrealize (child);
}
}
diff --git a/goffice/canvas/goc-item.c b/goffice/canvas/goc-item.c
index 74b8dfd..0b0bfda 100644
--- a/goffice/canvas/goc-item.c
+++ b/goffice/canvas/goc-item.c
@@ -101,6 +101,28 @@ goc_item_leave_notify (GocItem *item, double x, double y)
}
static void
+goc_item_realize (GocItem *item)
+{
+ if (item->realized)
+ g_warning ("Duplicate realize for %p %s\n",
+ item,
+ g_type_name_from_instance ((GTypeInstance*)item));
+ else
+ item->realized = TRUE;
+}
+
+static void
+goc_item_unrealize (GocItem *item)
+{
+ if (item->realized)
+ item->realized = FALSE;
+ else
+ g_warning ("Duplicate unrealize for %p %s\n",
+ item,
+ g_type_name_from_instance ((GTypeInstance*)item));
+}
+
+static void
goc_item_dispose (GObject *object)
{
GocItem *item = GOC_ITEM (object);
@@ -125,6 +147,8 @@ goc_item_class_init (GocItemClass *item_klass)
GObjectClass *obj_klass = (GObjectClass *) item_klass;
item_parent_class = g_type_class_peek_parent (item_klass);
+ item_klass->realize = goc_item_realize;
+ item_klass->unrealize = goc_item_unrealize;
item_klass->button_pressed = goc_item_button_pressed;
item_klass->button2_pressed = goc_item_button2_pressed;
item_klass->button_released = goc_item_button_released;
@@ -158,16 +182,16 @@ goc_item_new (GocGroup *group, GType type, const gchar *first_arg_name, ...)
goc_group_add_child (group, item);
+ /* FIXME: Due to contruction-only arguments, this needs to be
+ merged with the g_object_new above. We cannot do this
+ right now due to problems in GocWidget. */
va_start (args, first_arg_name);
g_object_set_valist (G_OBJECT (item), first_arg_name, args);
va_end (args);
- if (GTK_WIDGET_REALIZED (item->canvas)) {
- GocItemClass *klass = GOC_ITEM_GET_CLASS (item);
- if (klass->realize)
- klass->realize (item);
- item->realized = TRUE;
- }
+ /* This is probably a no-op. goc_group_add_child did it. */
+ if (GOC_ITEM (group)->realized)
+ _goc_item_realize (item);
return item;
}
@@ -399,9 +423,7 @@ _goc_item_realize (GocItem *item)
{
if (!item->realized) {
GocItemClass *klass = GOC_ITEM_GET_CLASS (item);
- if (klass->realize)
- klass->realize (item);
- item->realized = TRUE;
+ klass->realize (item);
}
}
@@ -410,8 +432,6 @@ _goc_item_unrealize (GocItem *item)
{
if (item->realized) {
GocItemClass *klass = GOC_ITEM_GET_CLASS (item);
- if (klass->unrealize)
- klass->unrealize (item);
- item->realized = FALSE;
+ klass->unrealize (item);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]