From a1a8696ccea253c3f0b05dad4a689dfd6f908109 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Thu, 6 Sep 2007 18:37:17 +0000 Subject: [PATCH] Introduce start_document_refreshes start_document_refreshes performs the NULL-pointer checks that previously all callers to start_document_refresh must perform and then calls start_document_refresh. --- src/document/refresh.c | 17 ++++++++++++++++- src/document/refresh.h | 2 +- src/session/session.c | 8 +------- src/viewer/text/draw.c | 8 +------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/document/refresh.c b/src/document/refresh.c index cb8cc9fbf..795f22e2a 100644 --- a/src/document/refresh.c +++ b/src/document/refresh.c @@ -94,7 +94,7 @@ do_document_refresh(void *data) } } -void +static void start_document_refresh(struct document_refresh *refresh, struct session *ses) { milliseconds_T minimum = (milliseconds_T) get_opt_int("document.browse.minimum_refresh_time", ses); @@ -120,3 +120,18 @@ start_document_refresh(struct document_refresh *refresh, struct session *ses) install_timer(&refresh->timer, time, do_document_refresh, ses); } + +void +start_document_refreshes(struct session *ses) +{ + + assert(ses); + + if (!ses->doc_view + || !ses->doc_view->document + || !ses->doc_view->document->refresh + || !get_opt_bool("document.browse.refresh", ses)) + return; + + start_document_refresh(ses->doc_view->document->refresh, ses); +} diff --git a/src/document/refresh.h b/src/document/refresh.h index f9b4c9c5b..2d8732cd8 100644 --- a/src/document/refresh.h +++ b/src/document/refresh.h @@ -16,6 +16,6 @@ struct document_refresh { struct document_refresh *init_document_refresh(unsigned char *url, unsigned long seconds); void done_document_refresh(struct document_refresh *refresh); void kill_document_refresh(struct document_refresh *refresh); -void start_document_refresh(struct document_refresh *refresh, struct session *ses); +void start_document_refreshes(struct session *ses); #endif diff --git a/src/session/session.c b/src/session/session.c index 709809639..34d83bd65 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -588,13 +588,7 @@ doc_loading_callback(struct download *download, struct session *ses) load_ecmascript_imports(ses, ses->doc_view); process_file_requests(ses); - if (ses->doc_view - && ses->doc_view->document - && ses->doc_view->document->refresh - && get_opt_bool("document.browse.refresh", ses)) { - start_document_refresh(ses->doc_view->document->refresh, - ses); - } + start_document_refreshes(ses); if (download->state != S_OK) { print_error_dialog(ses, download->state, diff --git a/src/viewer/text/draw.c b/src/viewer/text/draw.c index 07df0f7fb..e0676ded7 100644 --- a/src/viewer/text/draw.c +++ b/src/viewer/text/draw.c @@ -351,13 +351,7 @@ draw_formatted(struct session *ses, int rerender) render_document_frames(ses, rerender); /* Rerendering kills the document refreshing so restart it. */ - if (ses->doc_view - && ses->doc_view->document - && ses->doc_view->document->refresh - && get_opt_bool("document.browse.refresh", ses)) { - start_document_refresh(ses->doc_view->document->refresh, - ses); - } + start_document_refreshes(ses); } if (ses->tab != get_current_tab(ses->tab->term))