All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pat Thoyts <patthoyts@users.sourceforge.net>
To: git@vger.kernel.org
Cc: paulus@samba.org
Subject: [PATCH] gitk: avoid a crash in Tk if the application is closed early
Date: 28 Feb 2009 00:19:02 +0000	[thread overview]
Message-ID: <87hc2fe7m1.fsf@users.sourceforge.net> (raw)


    This evades Tk bug [2645457] that can lead to a crash in gitk if
    the application is closed while the commits are still being read
    from the git subprocess. By calling update to flush all the
    outstanding geometry events we avoid the chance of trying to map a
    deleted window.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 gitk |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/gitk b/gitk
index 2b5265a..cd7ea2f 100755
--- a/gitk
+++ b/gitk
@@ -1795,6 +1795,7 @@ proc make_transient {window origin} {
 proc show_error {w top msg} {
     variable use_ttk
     set ttk [expr {$use_ttk ? "ttk" : ""}]
+    if {[wm state $top] eq "withdrawn"} { wm deiconify $top }
     message $w.m -text $msg -justify center -aspect 400
     pack $w.m -side top -fill x -padx 20 -pady 20
     ${ttk}::button $w.ok -default active -text [mc OK] -command "destroy $top"
@@ -10998,12 +10999,9 @@ proc init {args} {
     variable lserial 0
     variable isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
     setcoords
-    makewindow
-    # wait for the window to become visible
-    wm deiconify .
-    tkwait visibility .
+    wm withdraw .
     wm title . "[file tail $argv0]: [file tail [pwd]]"
-    readrefs
+    makewindow
 
     if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} {
         # create a view for the files/dirs specified on the command line
@@ -11034,11 +11032,20 @@ proc init {args} {
         }
     }
 
+    # wait for the window to become visible
+    wm deiconify .
+    tkwait visibility .
+
     if {[tk windowingsystem] eq "win32"} {
         focus -force .
         bind . <Control-F2> {console show}
     }
 
+    # flush all geometry events to prevent possible crash if someone exits
+    # during the following reads.
+    update
+
+    readrefs
     getcommits {}
 }
 
-- 
1.6.0.2.1172.ga5ed0

                 reply	other threads:[~2009-02-28  1:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hc2fe7m1.fsf@users.sourceforge.net \
    --to=patthoyts@users.sourceforge.net \
    --cc=git@vger.kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.