From a721f62be35ea1eac6b3fe2a50999dbf82bbb39a Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 24 Jul 2007 15:27:21 +0200 Subject: [PATCH] Bug 723: Always get the current frame when loading frame files This cleans up and changes the calling convention of load_additional_file(), so that it now grab its own doc_view using current_frame() and the struct session pointer in the file_to_load object. By always looking up the current frame, corruption of doc_view due to rerendering of the upper frame document is avoided. The fix extends commit 6afdbf608f805a4247759c1e00c48f8a31942032 by Witold, which moved the getting of doc_view in the other caller of load_additional_file(). The additional clean up ensures that any future users of load_additional_file() will not reintroduce a similar bug. A possible future optimization would be to change load_additional_file() to take the referrer as an argument. --- src/session/session.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/session/session.c b/src/session/session.c index d0d4e81cb..852c95bfc 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -699,9 +699,9 @@ request_additional_file(struct session *ses, unsigned char *name, struct uri *ur } static void -load_additional_file(struct file_to_load *ftl, struct document_view *doc_view, - enum cache_mode cache_mode) +load_additional_file(struct file_to_load *ftl, enum cache_mode cache_mode) { + struct document_view *doc_view = current_frame(ftl->ses); struct uri *referrer = doc_view && doc_view->document ? doc_view->document->uri : NULL; @@ -719,15 +719,12 @@ process_file_requests(struct session *ses) int more = 0; foreach (ftl, ses->more_files) { - struct document_view *doc_view; - if (ftl->req_sent) continue; ftl->req_sent = 1; - doc_view = current_frame(ses); - load_additional_file(ftl, doc_view, CACHE_MODE_NORMAL); + load_additional_file(ftl, CACHE_MODE_NORMAL); more = 1; } @@ -1194,7 +1191,6 @@ reload(struct session *ses, enum cache_mode cache_mode) if (have_location(ses)) { struct location *loc = cur_loc(ses); struct file_to_load *ftl; - struct document_view *doc_view = current_frame(ses); #ifdef CONFIG_ECMASCRIPT loc->vs.ecmascript_fragile = 1; @@ -1217,7 +1213,7 @@ reload(struct session *ses, enum cache_mode cache_mode) ftl->download.data = ftl; ftl->download.callback = (download_callback_T *) file_loading_callback; - load_additional_file(ftl, doc_view, cache_mode); + load_additional_file(ftl, cache_mode); } } }