From 54d25de3719137a71af3415d952f1f8eb1296d4c Mon Sep 17 00:00:00 2001 From: James Bursa Date: Fri, 30 Jul 2004 16:16:07 +0000 Subject: [project @ 2004-07-30 16:16:07 by bursa] Implement content_quit() and ro_gui_window_quit() to free resources on quit. svn path=/import/netsurf/; revision=1164 --- content/content.c | 33 ++++++++++++++++++++++++++++++++- content/content.h | 1 + desktop/netsurf.c | 3 ++- riscos/gui.c | 3 ++- riscos/gui.h | 1 + riscos/window.c | 11 +++++++++++ 6 files changed, 49 insertions(+), 3 deletions(-) diff --git a/content/content.c b/content/content.c index a30c72f2b..433169d6a 100644 --- a/content/content.c +++ b/content/content.c @@ -539,7 +539,7 @@ void content_clean(void) content_stop_check(c); } - /* attempt to shrike the memory cache (unused fresh contents) */ + /* attempt to shrink the memory cache (unused fresh contents) */ size = 0; next = 0; for (c = content_list; c; c = c->next) { @@ -613,6 +613,37 @@ void content_reset(struct content *c) } +/** + * Free all contents in the content_list. + */ + +void content_quit(void) +{ + bool progress = true; + struct content *c, *next; + + while (content_list && progress) { + progress = false; + for (c = content_list; c; c = next) { + next = c->next; + + if (c->user_list->next && + c->status != CONTENT_STATUS_ERROR) + /* content has users */ + continue; + + /* content can be destroyed */ + content_destroy(c); + progress = true; + } + } + + if (content_list) { + LOG(("bug: some contents could not be destroyed")); + } +} + + /** * Display content on screen. * diff --git a/content/content.h b/content/content.h index e441e6b36..b82a02ebc 100644 --- a/content/content.h +++ b/content/content.h @@ -268,6 +268,7 @@ void content_convert(struct content *c, int width, int height); void content_reformat(struct content *c, int width, int height); void content_clean(void); void content_reset(struct content *c); +void content_quit(void); void content_redraw(struct content *c, int x, int y, int width, int height, int clip_x0, int clip_y0, int clip_x1, int clip_y1, diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 5f12f74fd..dbbe7575c 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -96,8 +96,9 @@ void netsurf_poll(void) void netsurf_exit(void) { - fetch_quit(); gui_quit(); + content_quit(); + fetch_quit(); } diff --git a/riscos/gui.c b/riscos/gui.c index c89a2d22d..1b2e5178f 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -441,10 +441,11 @@ void gui_init2(void) void gui_quit(void) { + ro_gui_window_quit(); ro_gui_hotlist_save(); ro_gui_history_quit(); free(gui_sprites); - wimp_close_down(task_handle); + xwimp_close_down(task_handle); xhourglass_off(); } diff --git a/riscos/gui.h b/riscos/gui.h index 5374ce91f..005b3a036 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -162,6 +162,7 @@ bool ro_gui_401login_keypress(wimp_key *key); #endif /* in window.c */ +void ro_gui_window_quit(void); void ro_gui_window_click(struct gui_window *g, wimp_pointer *mouse); void ro_gui_window_open(struct gui_window *g, wimp_open *open); void ro_gui_window_redraw(struct gui_window *g, wimp_draw *redraw); diff --git a/riscos/window.c b/riscos/window.c index 0aeaa7c8a..bd321638c 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -302,6 +302,17 @@ void gui_window_destroy(struct gui_window *g) } +/** + * Destroy all browser windows. + */ + +void ro_gui_window_quit(void) +{ + while (window_list) + browser_window_destroy(window_list->bw); +} + + /** * Set the title of a browser window. * -- cgit v1.2.3