mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 13:06:49 +03:00
ensure gtk scaffolding destruction does not create memory errors
This commit is contained in:
parent
c82049eb84
commit
6e31dcaec4
@ -611,7 +611,6 @@ nserror nsgtk_menu_bar_destroy(struct nsgtk_bar_submenu *menu)
|
||||
free(menu->view_submenu->scaleview_submenu);
|
||||
free(menu->view_submenu);
|
||||
free(menu->nav_submenu);
|
||||
free(menu->tabs_submenu);
|
||||
free(menu->tools_submenu->developer_submenu);
|
||||
free(menu->tools_submenu);
|
||||
free(menu->help_submenu);
|
||||
@ -633,7 +632,6 @@ nserror nsgtk_burger_menu_destroy(struct nsgtk_burger_menu *menu)
|
||||
free(menu->view_submenu->scaleview_submenu);
|
||||
free(menu->view_submenu);
|
||||
free(menu->nav_submenu);
|
||||
free(menu->tabs_submenu);
|
||||
free(menu->tools_submenu->developer_submenu);
|
||||
free(menu->tools_submenu);
|
||||
free(menu->help_submenu);
|
||||
|
@ -145,7 +145,6 @@ struct nsgtk_bar_submenu {
|
||||
struct nsgtk_edit_menu *edit_submenu;
|
||||
struct nsgtk_view_menu *view_submenu;
|
||||
struct nsgtk_nav_menu *nav_submenu;
|
||||
struct nsgtk_tabs_submenu *tabs_submenu;
|
||||
struct nsgtk_tools_menu *tools_submenu;
|
||||
struct nsgtk_help_menu *help_submenu;
|
||||
};
|
||||
@ -165,9 +164,6 @@ struct nsgtk_burger_menu {
|
||||
GtkWidget *nav_menuitem;
|
||||
struct nsgtk_nav_menu *nav_submenu;
|
||||
|
||||
GtkWidget *tabs_menuitem;
|
||||
struct nsgtk_tabs_submenu *tabs_submenu;
|
||||
|
||||
GtkWidget *tools_menuitem;
|
||||
struct nsgtk_tools_menu *tools_submenu;
|
||||
|
||||
|
@ -75,6 +75,9 @@ struct nsgtk_scaffolding {
|
||||
/** tab widget holding displayed pages */
|
||||
GtkNotebook *notebook;
|
||||
|
||||
/** handler id for tabs remove callback */
|
||||
gulong tabs_remove_handler_id;
|
||||
|
||||
/** menu bar hierarchy */
|
||||
struct nsgtk_bar_submenu *menu_bar;
|
||||
|
||||
@ -171,8 +174,6 @@ popup_menu_show(struct nsgtk_popup_menu *menu, bool nav, bool cnp)
|
||||
}
|
||||
|
||||
|
||||
/* event handlers and support functions for them */
|
||||
|
||||
/**
|
||||
* resource cleanup function for window destruction.
|
||||
*
|
||||
@ -207,6 +208,8 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data)
|
||||
nsgtk_popup_menu_destroy(gs->popup_menu);
|
||||
nsgtk_link_menu_destroy(gs->link_menu);
|
||||
|
||||
g_signal_handler_disconnect(gs->notebook, gs->tabs_remove_handler_id);
|
||||
|
||||
free(gs);
|
||||
|
||||
if (scaf_list == NULL) {
|
||||
@ -425,6 +428,8 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
|
||||
guint page_num,
|
||||
struct nsgtk_scaffolding *gs)
|
||||
{
|
||||
gboolean visible;
|
||||
|
||||
/* if the scaffold is being destroyed it is not useful to
|
||||
* update the state, further many of the widgets may have
|
||||
* already been destroyed.
|
||||
@ -439,7 +444,7 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
|
||||
return;
|
||||
}
|
||||
|
||||
gboolean visible = gtk_notebook_get_show_tabs(gs->notebook);
|
||||
visible = gtk_notebook_get_show_tabs(gs->notebook);
|
||||
g_object_set(gs->menu_bar->view_submenu->tabs_menuitem,
|
||||
"visible", visible, NULL);
|
||||
g_object_set(gs->burger_menu->view_submenu->tabs_menuitem,
|
||||
@ -1548,7 +1553,7 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
||||
"page-added",
|
||||
G_CALLBACK(nsgtk_window_tabs_add),
|
||||
gs);
|
||||
g_signal_connect_after(gs->notebook,
|
||||
gs->tabs_remove_handler_id = g_signal_connect_after(gs->notebook,
|
||||
"page-removed",
|
||||
G_CALLBACK(nsgtk_window_tabs_remove),
|
||||
gs);
|
||||
|
@ -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");
|
||||
gint pagec;
|
||||
GtkWidget *addpage;
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user