[gegl-gtk] Prevent segfault when setting autoscale policy without node.



commit 8d92c7b97c6874941282f789e6f6c320290e5297
Author: jordi fita i mas <gmf trasto cat>
Date:   Sat Feb 1 16:58:34 2014 +0100

    Prevent segfault when setting autoscale policy without node.
    
    View helper actually checks for null pointer, but it did *after* getting
    its bounding box and that fails when the view has no node.
    
        *  gegl-gtk/internal/view-helper.c (update_autoscale): Get the
           node's bounding box only if there is a valid node.

 gegl-gtk/internal/view-helper.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gegl-gtk/internal/view-helper.c b/gegl-gtk/internal/view-helper.c
index a7fb653..0c7c8ea 100644
--- a/gegl-gtk/internal/view-helper.c
+++ b/gegl-gtk/internal/view-helper.c
@@ -132,11 +132,14 @@ static void
 update_autoscale(ViewHelper *self)
 {
     GdkRectangle viewport = self->widget_allocation;
-    GeglRectangle bbox = gegl_node_get_bounding_box(self->node);
-    model_rect_to_view_rect(self, &bbox);
+    GeglRectangle bbox;
+
+    if (!self->node || viewport.width < 0 || viewport.height < 0)
+        return;
 
-    if (!self->node || viewport.width < 0 || viewport.height < 0
-            || bbox.width < 0 || bbox.height < 0)
+    bbox = gegl_node_get_bounding_box(self->node);
+    model_rect_to_view_rect(self, &bbox);
+    if (bbox.width < 0 || bbox.height < 0)
         return;
 
     if (self->autoscale_policy == GEGL_GTK_VIEW_AUTOSCALE_WIDGET) {


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