diff --git a/contrib/python/hooks.py b/contrib/python/hooks.py
index 4aa69090..03e4585e 100644
--- a/contrib/python/hooks.py
+++ b/contrib/python/hooks.py
@@ -36,6 +36,9 @@ def pre_format_html_hook(url, html):
if re.search("cygwin\.com", url):
html2 = re.sub("
conn;
+ struct connection *conn;
assert(old);
@@ -1029,7 +1029,9 @@ move_download(struct download *old, struct download *new,
* example the file protocol loads it's object immediately. This is
* catched by the result state check below. */
- new->conn = old->conn;
+ conn = old->conn;
+
+ new->conn = conn;
new->cached = old->cached;
new->prev_error = old->prev_error;
new->progress = old->progress;
@@ -1037,8 +1039,12 @@ move_download(struct download *old, struct download *new,
new->pri = newpri;
if (is_in_result_state(old->state)) {
- if (new->callback)
+ /* Ensure that new->conn is always "valid", that is NULL if the
+ * connection has been detached and non-NULL otherwise. */
+ if (new->callback) {
+ new->conn = NULL;
new->callback(new, new->data);
+ }
return;
}
diff --git a/src/session/download.c b/src/session/download.c
index 3b0fa81b..bc6f732e 100644
--- a/src/session/download.c
+++ b/src/session/download.c
@@ -967,10 +967,7 @@ tp_display(struct type_query *type_query)
new->callback = (download_callback_T *) doc_loading_callback;
new->data = ses;
- if (is_in_progress_state(old->state))
- move_download(old, new, PRI_MAIN);
- else
- new->state = old->state;
+ move_download(old, new, PRI_MAIN);
}
display_timer(ses);
diff --git a/src/session/session.c b/src/session/session.c
index 9e18a02e..37845b9e 100644
--- a/src/session/session.c
+++ b/src/session/session.c
@@ -604,11 +604,19 @@ doc_loading_callback(struct download *download, struct session *ses)
print_screen_status(ses);
#ifdef CONFIG_GLOBHIST
- if (download->conn && download->pri != PRI_CSS) {
+ if (download->pri != PRI_CSS) {
unsigned char *title = ses->doc_view->document->title;
- struct uri *uri = download->conn->proxied_uri;
+ struct uri *uri;
- add_global_history_item(struri(uri), title, time(NULL));
+ if (download->conn)
+ uri = download->conn->proxied_uri;
+ else if (download->cached)
+ uri = download->cached->uri;
+ else
+ uri = NULL;
+
+ if (uri)
+ add_global_history_item(struri(uri), title, time(NULL));
}
#endif
|