{"thread":{"id":"52932","subject":"[PATCH] gitk: fix fatal error by dropping duplicated requests","startedAt":"2020-03-03T22:46:36Z","lastAt":"2020-03-03T22:46:36Z","messageCount":1,"participants":["Max Kirillov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"392828","messageId":"20200303223907.5308-1-max@max630.net","threadId":"52932","inReplyTo":null,"subject":"[PATCH] gitk: fix fatal error by dropping duplicated requests","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2020-03-03T22:39:07Z","receivedAt":"2020-03-03T22:46:36Z","isPatch":true,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"During fast UI actions there may happen a fatal error message due to undefined\n$blobdifffd($ids). It happens because 2 same requests happen to be started.\nThen first one to complete wipes the $ids from blobdifffd, causing the second\nto fail. Then no diff is displayed in that gitk process anymore, so it has\nto be restarted. To reproduce one could fast click a big commit line twice, for\nexample, but I believe it is not the only case.\n\nFix by not starting a request if there is already one with the same $ids.\nIt does not seem to cause any malfunctioning when triggered.\n\nSigned-off-by: Max Kirillov <max@max630.net>\n---\n gitk | 10 +++++++++-\n 1 file changed, 9 insertions(+), 1 deletion(-)\n\ndiff --git a/gitk b/gitk\nindex da84e22dd4..3919ba85b1 100755\n--- a/gitk\n+++ b/gitk\n@@ -8009,6 +8009,10 @@ proc getblobdiffs {ids} {\n     global limitdiffs vfilelimit curview\n     global git_version\n \n+    if {[info exists blobdifffd($ids)]} {\n+\treturn\n+    }\n+\n     set textconv {}\n     if {[package vcompare $git_version \"1.6.1\"] >= 0} {\n \tset textconv \"--textconv\"\n@@ -9145,6 +9149,11 @@ proc do_cmp_commits {a b} {\n proc diffcommits {a b} {\n     global diffcontext diffids blobdifffd diffinhdr currdiffsubmod\n \n+    set diffids [list commits $a $b]\n+    if {[info exists blobdifffd($diffids)]} {\n+\treturn\n+    }\n+\n     set tmpdir [gitknewtmpdir]\n     set fna [file join $tmpdir \"commit-[string range $a 0 7]\"]\n     set fnb [file join $tmpdir \"commit-[string range $b 0 7]\"]\n@@ -9161,7 +9170,6 @@ proc diffcommits {a b} {\n \terror_popup [mc \"Error diffing commits: %s\" $err]\n \treturn\n     }\n-    set diffids [list commits $a $b]\n     set blobdifffd($diffids) $fd\n     set diffinhdr 0\n     set currdiffsubmod \"\"\n-- \n2.19.0.1202.g68e1e8f04e\n\n"}]}