From 6e31dcaec4a88ec1da3ae60e114fa256b77e5597 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 13 Oct 2019 01:52:22 +0100 Subject: ensure gtk scaffolding destruction does not create memory errors --- frontends/gtk/tabs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'frontends/gtk/tabs.c') diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c index 54aa5faf4..76fd02f89 100644 --- a/frontends/gtk/tabs.c +++ b/frontends/gtk/tabs.c @@ -312,14 +312,19 @@ nsgtk_tab_add_newtab(GtkNotebook *notebook) static void nsgtk_tab_visibility_update(GtkNotebook *notebook, GtkWidget *child, guint page) { - gint pagec = gtk_notebook_get_n_pages(notebook); - GtkWidget *addpage = g_object_get_data(G_OBJECT(notebook), "addtab"); - - if (addpage != NULL) { - pagec--; /* skip the add tab */ - if ((gint)page == pagec) { - /* ensure the add new tab cannot be current */ - gtk_notebook_set_current_page(notebook, page - 1); + gint pagec; + GtkWidget *addpage; + + pagec = gtk_notebook_get_n_pages(notebook); + if (pagec > 1) { + addpage = g_object_get_data(G_OBJECT(notebook), "addtab"); + if (addpage != NULL) { + pagec--; /* skip the add tab */ + if ((gint)page == pagec) { + /* ensure the add new tab cannot be current */ + gtk_notebook_set_current_page(notebook, + page - 1); + } } } -- cgit v1.2.3