r7418 - mugshot-client/trunk/common/stacker



Author: otaylor
Date: 2008-04-11 14:42:34 -0500 (Fri, 11 Apr 2008)
New Revision: 7418

Modified:
   mugshot-client/trunk/common/stacker/hippo-canvas-block.c
   mugshot-client/trunk/common/stacker/hippo-canvas-stack.c
Log:
Fix HIPPO_IS_BLOCK(block) warnings 
http://bugzilla.mugshot.org/show_bug.cgi?id=1395

hippo-canvas-stack.c: Dispose canvas items, don't just destroy them
 (prevents leakage, because of a
   parent->child->style->parent 
  refcount cycle in HippoCanvas)
hippo-canvas-block.c: Guard against canvas_block->block being null
  when updating the timestamp, if someone creates a canvas block
  with no block or sets the blockto NULL.


Modified: mugshot-client/trunk/common/stacker/hippo-canvas-block.c
===================================================================
--- mugshot-client/trunk/common/stacker/hippo-canvas-block.c	2008-04-10 20:08:19 UTC (rev 7417)
+++ mugshot-client/trunk/common/stacker/hippo-canvas-block.c	2008-04-11 19:42:34 UTC (rev 7418)
@@ -168,9 +168,6 @@
     char *when;
     gboolean nonempty;
 
-    if (canvas_block->block == NULL)
-        return FALSE;
-
     server_time_now = hippo_current_time_ms() + hippo_actions_get_server_time_offset(canvas_block->actions);
     
     when = hippo_format_time_ago((GTime) (server_time_now / 1000), age);
@@ -189,8 +186,11 @@
 update_time(HippoCanvasBlock *canvas_block)
 {
     if (canvas_block->age_item) {
-        canvas_block->age_set = set_timestamp_item(canvas_block, canvas_block->age_parent, canvas_block->age_item, 
-                                                   (GTime) (hippo_block_get_timestamp(canvas_block->block) / 1000));
+        if (canvas_block->block == NULL)
+            canvas_block->age_set = FALSE;
+        else
+            canvas_block->age_set = set_timestamp_item(canvas_block, canvas_block->age_parent, canvas_block->age_item, 
+                                                       (GTime) (hippo_block_get_timestamp(canvas_block->block) / 1000));
         
         hippo_canvas_item_set_visible(canvas_block->age_item,
                                       canvas_block->age_set);
@@ -203,10 +203,14 @@
 update_original_age(HippoCanvasBlock *canvas_block)
 {
     if (canvas_block->original_age_item) {
-        canvas_block->original_age_set =
-            set_timestamp_item(canvas_block,
-                               canvas_block->original_age_box, 
-                               canvas_block->original_age_item, canvas_block->original_age);
+        if (canvas_block->block == NULL)
+            canvas_block->original_age_set = FALSE;
+        else
+            canvas_block->original_age_set =
+                set_timestamp_item(canvas_block,
+                                   canvas_block->original_age_box, 
+                                   canvas_block->original_age_item, canvas_block->original_age);
+        
         hippo_canvas_item_set_visible(HIPPO_CANVAS_ITEM(canvas_block->original_age_box),
                                       canvas_block->expanded && canvas_block->original_age_set);
     }

Modified: mugshot-client/trunk/common/stacker/hippo-canvas-stack.c
===================================================================
--- mugshot-client/trunk/common/stacker/hippo-canvas-stack.c	2008-04-10 20:08:19 UTC (rev 7417)
+++ mugshot-client/trunk/common/stacker/hippo-canvas-stack.c	2008-04-11 19:42:34 UTC (rev 7418)
@@ -171,7 +171,7 @@
             children = g_list_reverse(children);
         while (count > canvas_stack->max_blocks) {
             g_assert(children != NULL);
-            hippo_canvas_box_remove(HIPPO_CANVAS_BOX(canvas_stack), children->data);
+            hippo_canvas_item_destroy(children->data);
             children = g_list_remove(children, children->data);
             --count;
         }
@@ -369,12 +369,8 @@
 
     item = find_block_item(canvas_stack, block);
 
-    if (item != NULL) {
-        g_object_set(G_OBJECT(item),
-                     "block", NULL,
-                     NULL);
-        hippo_canvas_box_remove(HIPPO_CANVAS_BOX(canvas_stack), item);
-    }
+    if (item != NULL)
+        hippo_canvas_item_destroy(item);
 }
 
 typedef struct {
@@ -459,7 +455,7 @@
 
     sort_timestamp = hippo_block_get_sort_timestamp(child_block);
     if (sort_timestamp < stack->min_timestamp)
-        hippo_canvas_box_remove(HIPPO_CANVAS_BOX(stack), child);
+        hippo_canvas_item_destroy(HIPPO_CANVAS_ITEM(child));
 
     g_object_unref(child_block);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]