mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 06:21:45 +03:00
ensure menu resources are released
this ensures all the menu resources are freed when the containing window receives the destroy signal. Previously these resources were leaked.
This commit is contained in:
parent
fed47dc35b
commit
8e986ae214
@ -263,8 +263,8 @@ nsgtk_menu_toolbars_submenu(GtkAccelGroup *group)
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_developer_submenu *nsgtk_menu_developer_submenu(
|
||||
GtkAccelGroup *group)
|
||||
static struct nsgtk_developer_submenu *
|
||||
nsgtk_menu_developer_submenu(GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_developer_submenu *dmenu =
|
||||
malloc(sizeof(struct nsgtk_developer_submenu));
|
||||
@ -423,7 +423,6 @@ static struct nsgtk_nav_menu *nsgtk_menu_nav_submenu(GtkAccelGroup *group)
|
||||
ADD_SEP(nav, ret);
|
||||
IMAGE_ITEM(nav, openlocation, gtkOpenLocation, ret, group);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -597,3 +596,73 @@ nsgtk_link_menu_create(GtkAccelGroup *group)
|
||||
|
||||
return nmenu;
|
||||
}
|
||||
|
||||
|
||||
/* exported function documented in gtk/menu.h */
|
||||
nserror nsgtk_menu_bar_destroy(struct nsgtk_bar_submenu *menu)
|
||||
{
|
||||
gtk_widget_destroy(GTK_WIDGET(menu->bar_menu));
|
||||
|
||||
free(menu->file_submenu->export_submenu);
|
||||
free(menu->file_submenu);
|
||||
free(menu->edit_submenu);
|
||||
free(menu->view_submenu->tabs_submenu);
|
||||
free(menu->view_submenu->toolbars_submenu);
|
||||
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);
|
||||
free(menu);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* exported function documented in gtk/menu.h */
|
||||
nserror nsgtk_burger_menu_destroy(struct nsgtk_burger_menu *menu)
|
||||
{
|
||||
gtk_widget_destroy(GTK_WIDGET(menu->burger_menu));
|
||||
|
||||
free(menu->file_submenu->export_submenu);
|
||||
free(menu->file_submenu);
|
||||
free(menu->edit_submenu);
|
||||
free(menu->view_submenu->tabs_submenu);
|
||||
free(menu->view_submenu->toolbars_submenu);
|
||||
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);
|
||||
free(menu);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/* exported function documented in gtk/menu.h */
|
||||
nserror nsgtk_popup_menu_destroy(struct nsgtk_popup_menu *menu)
|
||||
{
|
||||
gtk_widget_destroy(GTK_WIDGET(menu->popup_menu));
|
||||
|
||||
free(menu->toolbars_submenu);
|
||||
free(menu->tools_submenu->developer_submenu);
|
||||
free(menu->tools_submenu);
|
||||
free(menu);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/* exported function documented in gtk/menu.h */
|
||||
nserror nsgtk_link_menu_destroy(struct nsgtk_link_menu *menu)
|
||||
{
|
||||
gtk_widget_destroy(GTK_WIDGET(menu->link_menu));
|
||||
|
||||
free(menu);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
@ -210,27 +210,82 @@ struct nsgtk_link_menu {
|
||||
GtkWidget *copy_menuitem;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create main menubar menu.
|
||||
*/
|
||||
struct nsgtk_bar_submenu *nsgtk_menu_bar_create(GtkMenuShell *menubar, GtkAccelGroup *group);
|
||||
|
||||
|
||||
/**
|
||||
* Generate burger menu.
|
||||
*
|
||||
* \param accelerator group to use with menu
|
||||
* \return new menu structure or NULL on error
|
||||
*/
|
||||
struct nsgtk_burger_menu *nsgtk_burger_menu_create(GtkAccelGroup *group);
|
||||
|
||||
|
||||
/**
|
||||
* Generate right click popup menu.
|
||||
*
|
||||
* \param accelerator group to use with menu
|
||||
* \return new menu structure or NULL on error
|
||||
*/
|
||||
struct nsgtk_popup_menu *nsgtk_popup_menu_create(GtkAccelGroup *group);
|
||||
|
||||
|
||||
/**
|
||||
* Generate context sensitive link popup menu.
|
||||
*
|
||||
* \param accelerator group to use with menu
|
||||
* \return new menu structure or NULL on error
|
||||
*/
|
||||
struct nsgtk_link_menu *nsgtk_link_menu_create(GtkAccelGroup *group);
|
||||
|
||||
|
||||
/**
|
||||
* destroy bar menu
|
||||
*
|
||||
* destroys the gtk widgets associated with menu and frees all storage.
|
||||
*
|
||||
* \param menu menu to destroy
|
||||
* \return NSERROR_OK and menu destroyed on success else error code
|
||||
*/
|
||||
nserror nsgtk_menu_bar_destroy(struct nsgtk_bar_submenu *menu);
|
||||
|
||||
|
||||
/**
|
||||
* destroy burger menu
|
||||
*
|
||||
* destroys the gtk widgets associated with menu and frees all storage.
|
||||
*
|
||||
* \param menu menu to destroy
|
||||
* \return NSERROR_OK and menu destroyed on success else error code
|
||||
*/
|
||||
nserror nsgtk_burger_menu_destroy(struct nsgtk_burger_menu *menu);
|
||||
|
||||
|
||||
/**
|
||||
* destroy popup menu
|
||||
*
|
||||
* destroys the gtk widgets associated with menu and frees all storage.
|
||||
*
|
||||
* \param menu menu to destroy
|
||||
* \return NSERROR_OK and menu destroyed on success else error code
|
||||
*/
|
||||
nserror nsgtk_popup_menu_destroy(struct nsgtk_popup_menu *menu);
|
||||
|
||||
|
||||
/**
|
||||
* destroy link menu
|
||||
*
|
||||
* destroys the gtk widgets associated with menu and frees all storage.
|
||||
*
|
||||
* \param menu menu to destroy
|
||||
* \return NSERROR_OK and menu destroyed on success else error code
|
||||
*/
|
||||
nserror nsgtk_link_menu_destroy(struct nsgtk_link_menu *menu);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -87,7 +87,7 @@ struct nsgtk_scaffolding {
|
||||
/** link popup menu */
|
||||
struct nsgtk_link_menu *link_menu;
|
||||
|
||||
/** menu entries widgets for sensativity adjustment */
|
||||
/** menu entries widgets for sensitivity adjustment */
|
||||
struct nsgtk_menu menus[PLACEHOLDER_BUTTON];
|
||||
};
|
||||
|
||||
@ -201,6 +201,14 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data)
|
||||
|
||||
NSLOG(netsurf, INFO, "scaffold list head: %p", scaf_list);
|
||||
|
||||
/* ensure menu resources are freed */
|
||||
nsgtk_menu_bar_destroy(gs->menu_bar);
|
||||
nsgtk_burger_menu_destroy(gs->burger_menu);
|
||||
nsgtk_popup_menu_destroy(gs->popup_menu);
|
||||
nsgtk_link_menu_destroy(gs->link_menu);
|
||||
|
||||
free(gs);
|
||||
|
||||
if (scaf_list == NULL) {
|
||||
/* no more open windows - stop the browser */
|
||||
nsgtk_complete = true;
|
||||
@ -1008,7 +1016,7 @@ create_scaffolding_link_menu(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
|
||||
*/
|
||||
static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
|
||||
{
|
||||
#define TOOLBAR_ITEM_p(identifier, name, iconame) \
|
||||
#define TOOLBAR_ITEM_p(identifier, name, iconame) \
|
||||
g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu; \
|
||||
g->menus[identifier].iconname = iconame;
|
||||
#define TOOLBAR_ITEM_y(identifier, name, iconame) \
|
||||
@ -1393,6 +1401,7 @@ nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs)
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in gtk/scaffolding.h */
|
||||
nserror nsgtk_scaffolding_burger_menu(struct nsgtk_scaffolding *gs)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user