summaryrefslogtreecommitdiff
path: root/frontends/gtk/scaffolding.c
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/gtk/scaffolding.c')
-rw-r--r--frontends/gtk/scaffolding.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index f08d5d0d0..f9d4f6d67 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -18,6 +18,7 @@
#include <gtk/gtk.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
#include "utils/utils.h"
@@ -192,6 +193,18 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data)
nsgtk_local_history_hide();
+ /* ensure scaffolding being destroyed is not current */
+ if (scaf_current == gs) {
+ scaf_current = NULL;
+ /* attempt to select nearest scaffold instead of just selecting the first */
+ if (gs->prev != NULL) {
+ scaf_current = gs->prev;
+ } else if (gs->next != NULL) {
+ scaf_current = gs->next;
+ }
+ }
+
+ /* remove scaffolding from list */
if (gs->prev != NULL) {
gs->prev->next = gs->next;
} else {