diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-12-24 00:11:42 +0000 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2011-12-24 00:11:42 +0000 |
commit | 8f9ce31038105cd975c88e0008f2e14ecab59240 (patch) | |
tree | 18f6948b5427f02e3df36e1fb09eedc8f91f8e96 /src | |
parent | 34604c7fe4530c8a9b8510497de51367f550df99 (diff) |
Ensure old Cairo surfaces get deleted
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.c | 60 | ||||
-rw-r--r-- | src/mainwindow.h | 2 | ||||
-rw-r--r-- | src/objects.c | 3 | ||||
-rw-r--r-- | src/slideshow.c | 44 | ||||
-rw-r--r-- | src/slideshow.h | 5 |
5 files changed, 58 insertions, 56 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index 3895c73..a9c52f8 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -330,15 +330,22 @@ static gint start_slideshow_sig(GtkWidget *widget, struct presentation *p) } -void notify_slide_changed(struct presentation *p) +void notify_slide_changed(struct presentation *p, struct slide *np) { p->cur_tool->deselect(p->editing_object, p->cur_tool); p->editing_object = NULL; + + if ( p->cur_edit_slide->rendered_edit != NULL ) { + cairo_surface_destroy(p->cur_edit_slide->rendered_edit); + p->cur_edit_slide->rendered_edit = NULL; + } + p->cur_edit_slide = np; + update_toolbar(p); redraw_slide(p->cur_edit_slide); - if ( p->slideshow != NULL ) { - notify_slideshow_slide_changed(p); + if ( (p->slideshow != NULL) && p->slideshow_linked ) { + notify_slideshow_slide_changed(p, np); } } @@ -351,8 +358,7 @@ static gint add_slide_sig(GtkWidget *widget, struct presentation *p) cur_slide_number = slide_number(p, p->cur_edit_slide); new = add_slide(p, cur_slide_number); - p->cur_edit_slide = new; - notify_slide_changed(p); + notify_slide_changed(p, new); return FALSE; } @@ -360,14 +366,7 @@ static gint add_slide_sig(GtkWidget *widget, struct presentation *p) static gint first_slide_sig(GtkWidget *widget, struct presentation *p) { - p->cur_edit_slide = p->slides[0]; - notify_slide_changed(p); - - if ( p->slideshow_linked ) { - p->cur_proj_slide = p->cur_edit_slide; - notify_slideshow_slide_changed(p); - } - + notify_slide_changed(p, p->slides[0]); return FALSE; } @@ -379,13 +378,7 @@ static gint prev_slide_sig(GtkWidget *widget, struct presentation *p) cur_slide_number = slide_number(p, p->cur_edit_slide); if ( cur_slide_number == 0 ) return FALSE; - p->cur_edit_slide = p->slides[cur_slide_number-1]; - notify_slide_changed(p); - - if ( p->slideshow_linked ) { - p->cur_proj_slide = p->cur_edit_slide; - notify_slideshow_slide_changed(p); - } + notify_slide_changed(p, p->slides[cur_slide_number-1]); return FALSE; } @@ -398,13 +391,7 @@ static gint next_slide_sig(GtkWidget *widget, struct presentation *p) cur_slide_number = slide_number(p, p->cur_edit_slide); if ( cur_slide_number == p->num_slides-1 ) return FALSE; - p->cur_edit_slide = p->slides[cur_slide_number+1]; - notify_slide_changed(p); - - if ( p->slideshow_linked ) { - p->cur_proj_slide = p->cur_edit_slide; - notify_slideshow_slide_changed(p); - } + notify_slide_changed(p, p->slides[cur_slide_number+1]); return FALSE; } @@ -412,13 +399,7 @@ static gint next_slide_sig(GtkWidget *widget, struct presentation *p) static gint last_slide_sig(GtkWidget *widget, struct presentation *p) { - p->cur_edit_slide = p->slides[p->num_slides-1]; - notify_slide_changed(p); - - if ( p->slideshow_linked ) { - p->cur_proj_slide = p->cur_edit_slide; - notify_slideshow_slide_changed(p); - } + notify_slide_changed(p, p->slides[p->num_slides-1]); return FALSE; } @@ -653,7 +634,10 @@ void redraw_overlay(struct presentation *p) static gboolean im_commit_sig(GtkIMContext *im, gchar *str, struct presentation *p) { - if ( p->editing_object == NULL ) return FALSE; + if ( p->editing_object == NULL ) { + printf("IM keypress: %s\n", str); + return FALSE; + } if ( p->editing_object->type != OBJ_TEXT ) return FALSE; p->cur_tool->im_commit(p->editing_object, str, p->cur_tool); @@ -703,11 +687,7 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, case GDK_KEY_b : if ( p->slideshow != NULL ) { if ( p->prefs->b_splits ) { - p->slideshow_linked = 1 - p->slideshow_linked; - if ( p->slideshow_linked ) { - p->cur_proj_slide = p->cur_edit_slide; - notify_slideshow_slide_changed(p); - } + toggle_slideshow_link(p); } else { p->ss_blank = 1-p->ss_blank; gdk_window_invalidate_rect( diff --git a/src/mainwindow.h b/src/mainwindow.h index feac092..3bfff44 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -29,7 +29,7 @@ extern int open_mainwindow(struct presentation *p); -extern void notify_slide_changed(struct presentation *p); +extern void notify_slide_changed(struct presentation *p, struct slide *np); extern void update_titlebar(struct presentation *p); extern void redraw_overlay(struct presentation *p); diff --git a/src/objects.c b/src/objects.c index f502b52..d2383c3 100644 --- a/src/objects.c +++ b/src/objects.c @@ -178,8 +178,9 @@ void notify_style_update(struct presentation *p, struct style *sty) } + /* Trigger redraw etc */ p->completely_empty = 0; - if ( changed ) notify_slide_changed(p); /* Trigger redraw etc */ + if ( changed ) notify_slide_changed(p, p->cur_edit_slide); } diff --git a/src/slideshow.c b/src/slideshow.c index 4a79d6f..4786784 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -85,8 +85,15 @@ static gboolean ss_expose_sig(GtkWidget *da, GdkEventExpose *event, } -void notify_slideshow_slide_changed(struct presentation *p) +void notify_slideshow_slide_changed(struct presentation *p, struct slide *np) { + if ( (p->cur_proj_slide != NULL) + && (p->cur_proj_slide->rendered_edit != NULL) ) + { + cairo_surface_destroy(p->cur_proj_slide->rendered_proj); + p->cur_proj_slide->rendered_proj = NULL; + } + p->cur_proj_slide = np; redraw_slide(p->cur_proj_slide); } @@ -109,17 +116,14 @@ static void change_slide(struct presentation *p, signed int n) if ( p->slideshow_linked ) { /* If we are currently "linked", update both. */ - p->cur_proj_slide = p->slides[cur_slide_number+n]; - p->cur_edit_slide = p->cur_proj_slide; - notify_slideshow_slide_changed(p); - notify_slide_changed(p); + notify_slideshow_slide_changed(p, p->slides[cur_slide_number+n]); + notify_slide_changed(p, p->slides[cur_slide_number+n]); } else { /* If we are not linked, a slide change on the "slideshow" * actually affects the editor. */ - p->cur_edit_slide = p->slides[cur_slide_number+n]; - notify_slide_changed(p); + notify_slide_changed(p, p->slides[cur_slide_number+n]); /* p->cur_proj_slide not changed */ } @@ -145,8 +149,26 @@ void end_slideshow(struct presentation *p) gtk_widget_destroy(p->ss_drawingarea); gtk_widget_destroy(p->slideshow); p->slideshow = NULL; + + if ( (p->cur_proj_slide != NULL) + && (p->cur_proj_slide->rendered_edit != NULL) ) + { + cairo_surface_destroy(p->cur_proj_slide->rendered_proj); + p->cur_proj_slide->rendered_proj = NULL; + } + p->cur_proj_slide = NULL; - notify_slide_changed(p); + redraw_overlay(p); +} + + +void toggle_slideshow_link(struct presentation *p) +{ + p->slideshow_linked = 1 - p->slideshow_linked; + if ( p->slideshow_linked ) { + p->cur_proj_slide = p->cur_edit_slide; + notify_slideshow_slide_changed(p, p->cur_proj_slide); + } } @@ -158,11 +180,7 @@ static gboolean ss_key_press_sig(GtkWidget *da, GdkEventKey *event, case GDK_KEY_B : case GDK_KEY_b : if ( p->prefs->b_splits ) { - p->slideshow_linked = 1 - p->slideshow_linked; - if ( p->slideshow_linked ) { - p->cur_proj_slide = p->cur_edit_slide; - notify_slideshow_slide_changed(p); - } + toggle_slideshow_link(p); } else { p->ss_blank = 1-p->ss_blank; gdk_window_invalidate_rect(p->ss_drawingarea->window, diff --git a/src/slideshow.h b/src/slideshow.h index 5b332c7..03418f7 100644 --- a/src/slideshow.h +++ b/src/slideshow.h @@ -30,7 +30,10 @@ extern void try_start_slideshow(struct presentation *p); -extern void notify_slideshow_slide_changed(struct presentation *p); +extern void notify_slideshow_slide_changed(struct presentation *p, + struct slide *np); + +extern void toggle_slideshow_link(struct presentation *p); extern void end_slideshow(struct presentation *p); |