diff --git a/src/scripting/python/document.c b/src/scripting/python/document.c index c7a1399f..76decbef 100644 --- a/src/scripting/python/document.c +++ b/src/scripting/python/document.c @@ -9,8 +9,9 @@ #include "elinks.h" #include "cache/cache.h" +#include "document/document.h" +#include "document/view.h" #include "scripting/python/core.h" -#include "session/location.h" #include "session/session.h" /* Python interface to get the current document's body. */ @@ -23,8 +24,9 @@ If a document is being viewed, return its body; otherwise return None.\n"); static PyObject * python_current_document(PyObject *self, PyObject *args) { - if (python_ses && have_location(python_ses)) { - struct cache_entry *cached = find_in_cache(cur_loc(python_ses)->vs.uri); + if (python_ses && python_ses->doc_view + && python_ses->doc_view->document) { + struct cache_entry *cached = python_ses->doc_view->document->cached; struct fragment *f = cached ? cached->frag.next : NULL; if (f) return PyString_FromStringAndSize(f->data, f->length); @@ -45,8 +47,9 @@ otherwise return None.\n"); static PyObject * python_current_header(PyObject *self, PyObject *args) { - if (python_ses && have_location(python_ses)) { - struct cache_entry *cached = find_in_cache(cur_loc(python_ses)->vs.uri); + if (python_ses && python_ses->doc_view + && python_ses->doc_view->document) { + struct cache_entry *cached = python_ses->doc_view->document->cached; if (cached && cached->head) return PyString_FromString(cached->head); diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 1b06ddff..2a1b672f 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -1028,7 +1028,8 @@ activate_link(struct session *ses, struct document_view *doc_view, * buttons in the group. Do it in this order because * further @find_form_state calls may reallocate * @doc_view->vs->form_info[] and thereby make the @fs - * pointer invalid. */ + * pointer invalid. This also allows us to re-use + * @fs in the loop. */ fs->state = 1; foreach (form, doc_view->document->forms) { struct form_control *fc; @@ -1040,10 +1041,8 @@ activate_link(struct session *ses, struct document_view *doc_view, if (fc->type == FC_RADIO && !xstrcmp(fc->name, link_fc->name) && fc != link_fc) { - struct form_state *frm_st; - - frm_st = find_form_state(doc_view, fc); - if (frm_st) frm_st->state = 0; + fs = find_form_state(doc_view, fc); + if (fs) fs->state = 0; } } }