diff options
author | Thomas White <taw@bitwiz.me.uk> | 2018-10-30 18:17:54 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2018-10-30 18:17:54 +0100 |
commit | ca4ecaf2b06e50fc2026e35b946409b719f72425 (patch) | |
tree | 887e7e2b20ae132ed53f29744d93c8901db9e84d /src/presentation.c | |
parent | 91f680b08931aaa43df551d18fdd4b6638fbac7b (diff) |
Fix reference counting for presentation/stylesheet GFiles
Diffstat (limited to 'src/presentation.c')
-rw-r--r-- | src/presentation.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/presentation.c b/src/presentation.c index fd55bf7..28f82a2 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -110,6 +110,7 @@ static void find_and_load_stylesheet(struct presentation *p, GFile *file) } /* Last resort is NULL stylesheet and SCInterpreter's defaults */ + /* We keep a reference to the GFile */ } @@ -168,6 +169,13 @@ int save_presentation(struct presentation *p, GFile *file, GFile *ssfile) if ( sr ) { fprintf(stderr, _("Couldn't save stylesheet\n")); } + if ( p->stylesheet_from != ssfile ) { + if ( p->stylesheet_from != NULL ) { + g_object_unref(p->stylesheet_from); + } + p->stylesheet_from = ssfile; + g_object_ref(p->stylesheet_from); + } } else { fprintf(stderr, _("Not updating default stylesheet\n")); sr = 0; @@ -176,7 +184,12 @@ int save_presentation(struct presentation *p, GFile *file, GFile *ssfile) if ( r || sr ) return 1; imagestore_set_parent(p->is, g_file_get_parent(file)); - p->file = file; + + if ( p->file != file ) { + if ( p->file != NULL ) g_object_unref(p->file); + p->file = file; + g_object_ref(p->file); + } p->saved = 1; update_titlebar(p->narrative_window); return 0; |