diff options
author | bptato <nincsnevem662@gmail.com> | 2024-07-23 19:20:41 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-07-23 19:23:05 +0200 |
commit | 40122721d3b25d3b7e75f93e64d88853d1c9c0f2 (patch) | |
tree | 1703a1026e933455d9557dbb51dcd2ad1a17d055 | |
parent | ba8ec92e2cf19e8e2b4c8d4d573e357798a1bcae (diff) | |
download | chawan-40122721d3b25d3b7e75f93e64d88853d1c9c0f2.tar.gz |
pager: fix dead containers left in replaceBackup
fixes the following bug: * click a link that redirects somewhere * go back * discard buffer (that had the link) * discard the new buffer then you would find yourself in a zombie buffer you previously discarded
-rw-r--r-- | src/local/container.nim | 3 | ||||
-rw-r--r-- | src/local/pager.nim | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/local/container.nim b/src/local/container.nim index 9dc9d552..805c1b80 100644 --- a/src/local/container.nim +++ b/src/local/container.nim @@ -142,6 +142,9 @@ type numLines*: int replace*: Container replaceBackup*: Container # for redirection; when set, we get discarded + # if we are referenced by another container, replaceRef is set so that we + # can clear ourselves on discard + replaceRef*: Container code*: int # note: this is not the status code, but the ConnectErrorCode. errorMessage*: string retry*: seq[URL] diff --git a/src/local/pager.nim b/src/local/pager.nim index 6430416f..e150507c 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -936,6 +936,10 @@ proc deleteContainer(pager: Pager; container, setTarget: Container) = if container.sourcepair != nil: container.sourcepair.sourcepair = nil container.sourcepair = nil + if container.replaceRef != nil: + container.replaceRef.replace = nil + container.replaceRef.replaceBackup = nil + container.replaceRef = nil if container.parent != nil: let parent = container.parent let n = parent.children.find(container) @@ -1225,8 +1229,10 @@ proc gotoURL(pager: Pager; request: Request; prevurl = none(URL); pager.replace(replace, container) if replaceBackup == nil: container.replace = replace + replace.replaceRef = container else: container.replaceBackup = replaceBackup + replaceBackup.replaceRef = container container.copyCursorPos(replace) else: pager.addContainer(container) |