[goffice] Canvas: fix cairo save imbalances.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Canvas: fix cairo save imbalances.
- Date: Mon, 25 Mar 2013 15:33:08 +0000 (UTC)
commit 1fde9d4cdd4729c888ec3b90d4ad8935ac73a826
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 25 11:32:50 2013 -0400
Canvas: fix cairo save imbalances.
ChangeLog | 5 +++++
goffice/canvas/goc-ellipse.c | 9 +++++++--
goffice/canvas/goc-item.c | 1 +
goffice/canvas/goc-path.c | 8 ++++++--
goffice/canvas/goc-polygon.c | 9 +++++++--
goffice/canvas/goc-polyline.c | 12 ++++++++----
6 files changed, 34 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7301395..9a2bcd0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-25 Morten Welinder <terra gnome org>
+
+ * goffice/canvas/goc-polyline.c (goc_polyline_draw): Fix cairo
+ save stack imbalance.
+
2013-03-23 Morten Welinder <terra gnome org>
* goffice/canvas/goc-item.c (goc_item_get_style_context): New
diff --git a/goffice/canvas/goc-ellipse.c b/goffice/canvas/goc-ellipse.c
index c79a4bd..f962961 100644
--- a/goffice/canvas/goc-ellipse.c
+++ b/goffice/canvas/goc-ellipse.c
@@ -215,18 +215,23 @@ static void
goc_ellipse_draw (GocItem const *item, cairo_t *cr)
{
gboolean scale_line_width = goc_styled_item_get_scale_line_width (GOC_STYLED_ITEM (item));
+ gboolean needs_restore;
+
cairo_save(cr);
+ needs_restore = TRUE;
if (goc_ellipse_prepare_draw (item, cr, 1)) {
go_styled_object_fill (GO_STYLED_OBJECT (item), cr, TRUE);
- if (!scale_line_width)
+ if (!scale_line_width) {
cairo_restore (cr);
+ needs_restore = FALSE;
+ }
if (go_styled_object_set_cairo_line (GO_STYLED_OBJECT (item), cr)) {
cairo_stroke (cr);
} else {
cairo_new_path (cr);
}
}
- if (scale_line_width)
+ if (needs_restore)
cairo_restore(cr);
}
diff --git a/goffice/canvas/goc-item.c b/goffice/canvas/goc-item.c
index 367db02..129fa7d 100644
--- a/goffice/canvas/goc-item.c
+++ b/goffice/canvas/goc-item.c
@@ -859,6 +859,7 @@ goc_item_get_style_context (const GocItem *item)
GtkWidgetPath *path;
path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GOC_TYPE_CANVAS);
gtk_widget_path_append_type (path,
G_TYPE_FROM_INSTANCE (item));
diff --git a/goffice/canvas/goc-path.c b/goffice/canvas/goc-path.c
index 268dbc6..3a95f0f 100644
--- a/goffice/canvas/goc-path.c
+++ b/goffice/canvas/goc-path.c
@@ -202,21 +202,25 @@ goc_path_draw (GocItem const *item, cairo_t *cr)
{
GocPath *path = GOC_PATH (item);
gboolean scale_line_width = goc_styled_item_get_scale_line_width (GOC_STYLED_ITEM (item));
+ gboolean needs_restore;
cairo_save(cr);
+ needs_restore = TRUE;
cairo_set_fill_rule (cr, path->fill_rule? CAIRO_FILL_RULE_EVEN_ODD: CAIRO_FILL_RULE_WINDING);
if (goc_path_prepare_draw (item, cr, 1)) {
if (path->closed)
go_styled_object_fill (GO_STYLED_OBJECT (item), cr, TRUE);
- if (!scale_line_width)
+ if (!scale_line_width) {
cairo_restore (cr);
+ needs_restore = FALSE;
+ }
if (go_styled_object_set_cairo_line (GO_STYLED_OBJECT (item), cr)) {
cairo_stroke (cr);
} else {
cairo_new_path (cr);
}
}
- if (scale_line_width)
+ if (needs_restore)
cairo_restore(cr);
}
diff --git a/goffice/canvas/goc-polygon.c b/goffice/canvas/goc-polygon.c
index 7e0b2a0..69637bb 100644
--- a/goffice/canvas/goc-polygon.c
+++ b/goffice/canvas/goc-polygon.c
@@ -294,19 +294,24 @@ static void
goc_polygon_draw (GocItem const *item, cairo_t *cr)
{
gboolean scale_line_width = goc_styled_item_get_scale_line_width (GOC_STYLED_ITEM (item));
+ gboolean needs_restore;
+
cairo_save (cr);
+ needs_restore = TRUE;
_goc_item_transform (item, cr, TRUE);
if (goc_polygon_prepare_path (item, cr, 1)) {
go_styled_object_fill (GO_STYLED_OBJECT (item), cr, TRUE);
- if (!scale_line_width)
+ if (!scale_line_width) {
cairo_restore (cr);
+ needs_restore = FALSE;
+ }
if (go_styled_object_set_cairo_line (GO_STYLED_OBJECT (item), cr))
cairo_stroke (cr);
else
cairo_new_path (cr);
}
- if (scale_line_width)
+ if (needs_restore)
cairo_restore (cr);
}
diff --git a/goffice/canvas/goc-polyline.c b/goffice/canvas/goc-polyline.c
index a98acb8..c71df09 100644
--- a/goffice/canvas/goc-polyline.c
+++ b/goffice/canvas/goc-polyline.c
@@ -111,8 +111,11 @@ goc_polyline_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
GocPolyline *polyline = GOC_POLYLINE (item);
unsigned i;
gboolean scale_line_width = goc_styled_item_get_scale_line_width (GOC_STYLED_ITEM (item));
+ gboolean needs_restore;
cairo_save (cr);
+ needs_restore = TRUE;
+
_goc_item_transform (item, cr, flag);
if (polyline->nb_points == 0)
return FALSE;
@@ -148,15 +151,17 @@ goc_polyline_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
}
}
- if (!scale_line_width)
+ if (!scale_line_width) {
cairo_restore (cr);
+ needs_restore = FALSE;
+ }
if (goc_styled_item_set_cairo_line (GOC_STYLED_ITEM (item), cr)) {
- if (!scale_line_width)
+ if (needs_restore)
cairo_restore (cr);
return TRUE;
}
- if (!scale_line_width)
+ if (needs_restore)
cairo_restore (cr);
return FALSE;
}
@@ -222,7 +227,6 @@ goc_polyline_draw (GocItem const *item, cairo_t *cr)
if (goc_polyline_prepare_draw (item, cr, 1)) {
cairo_stroke (cr);
}
- cairo_restore (cr);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]