mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
print: Use cairo_save/cairo_restore to manage temporary cairo changes
The print_weight_data function was making several cairo_translate calls and then doing some final cairo_translate calls with the goal of manually undoing any changes to cairo's state. Obviously, this is fragile. Cairo provides save/restore calls which solve this problem in a robust way. Switch to using these instead. Signed-off-by: Carl Worth <cworth@cworth.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7e7cbb0dce
commit
a6fd407626
1 changed files with 4 additions and 3 deletions
7
print.c
7
print.c
|
@ -290,6 +290,8 @@ static void print_weight_data (struct dive *dive, cairo_t *cr, int maxwidth, int
|
|||
char buffer[80];
|
||||
PangoLayout *layout;
|
||||
|
||||
cairo_save(cr);
|
||||
|
||||
layout = pango_cairo_create_layout(cr);
|
||||
pango_layout_set_height(layout,maxheight);
|
||||
pango_layout_set_width(layout, maxwidth);
|
||||
|
@ -339,10 +341,9 @@ static void print_weight_data (struct dive *dive, cairo_t *cr, int maxwidth, int
|
|||
unit_weight);
|
||||
pango_layout_set_text(layout, buffer, -1);
|
||||
pango_cairo_show_layout(cr, layout);
|
||||
/* undo translations */
|
||||
cairo_translate (cr, 0, -(weightsystemcounter * height) / (4 * (double) PANGO_SCALE));
|
||||
cairo_translate (cr, 0, -height / (3 * (double) PANGO_SCALE));
|
||||
g_object_unref (layout);
|
||||
|
||||
cairo_restore(cr);
|
||||
}
|
||||
|
||||
/* Print the dive OTUs */
|
||||
|
|
Loading…
Reference in a new issue