Skip to content

Commit

Permalink
Introduce start_document_refreshes
Browse files Browse the repository at this point in the history
start_document_refreshes performs the NULL-pointer checks that previously all callers to start_document_refresh must perform and then calls start_document_refresh.
  • Loading branch information
Miciah Dashiel Butler Masters authored and Miciah Dashiel Butler Masters committed Sep 6, 2007
1 parent 3421232 commit a1a8696
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
17 changes: 16 additions & 1 deletion src/document/refresh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
2 changes: 1 addition & 1 deletion src/document/refresh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 1 addition & 7 deletions src/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions src/viewer/text/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit a1a8696

Please sign in to comment.