From 3433214be95736ec537f93f49c6189f4b37b3330 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 8 Feb 2017 05:36:14 +0100 Subject: Substitution fixes --- src/narrative_window.c | 6 +++--- src/sc_parse.c | 15 ++++++++++----- src/sc_parse.h | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/narrative_window.c b/src/narrative_window.c index 04f42c7..ec5d956 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -273,14 +273,14 @@ static gint load_ss_response_sig(GtkWidget *d, gint response, SCBlock **stylesheets; - /* Substitute the style sheet */ - replace_stylesheet(nw->p, ss); - stylesheets = get_ss_list(nw->p); sc_editor_set_stylesheets(nw->sceditor, stylesheets); free(stylesheets); + /* Substitute the style sheet */ + replace_stylesheet(nw->p, ss); + /* Full rerender, first block may have * changed */ sc_editor_set_scblock(nw->sceditor, diff --git a/src/sc_parse.c b/src/sc_parse.c index 1018d24..ccc6f6a 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -218,14 +218,14 @@ void sc_block_substitute(SCBlock **top, SCBlock *old, SCBlock *new) new->next = old->next; *top = new; } else { - sc_block_delete(*top, old); + sc_block_unlink(*top, old); sc_block_append_p(new, *top); } } /* Delete "deleteme", which is somewhere under "top" */ -void sc_block_delete(SCBlock *top, SCBlock *deleteme) +void sc_block_unlink(SCBlock *top, SCBlock *deleteme) { SCBlock *parent = sc_find_parent(top, deleteme); if ( parent == NULL ) { @@ -240,19 +240,24 @@ void sc_block_delete(SCBlock *top, SCBlock *deleteme) if ( parent->child == deleteme ) { parent->child = NULL; } +} + +void sc_block_delete(SCBlock *top, SCBlock *deleteme) +{ + sc_block_unlink(top, deleteme); sc_block_free(deleteme); } - -/* Frees "bl" and all its children */ +/* Frees "bl" and all its children (but not the blocks following it) */ void sc_block_free(SCBlock *bl) { if ( bl->child != NULL ) { SCBlock *ch = bl->child; while ( ch != NULL ) { + SCBlock *next = ch->next; sc_block_free(ch); - ch = ch->next; + ch = next;; } } diff --git a/src/sc_parse.h b/src/sc_parse.h index a07901f..dfa3fab 100644 --- a/src/sc_parse.h +++ b/src/sc_parse.h @@ -60,6 +60,7 @@ extern SCBlock *sc_block_insert_after(SCBlock *afterme, char *name, char *opt, char *contents); extern void sc_block_delete(SCBlock *top, SCBlock *deleteme); +extern void sc_block_unlink(SCBlock *top, SCBlock *deleteme); extern SCBlock *find_last_child(SCBlock *bl); -- cgit v1.2.3