Re: [PATCH] git-gui: Call do_quit before destroying the main window
- From
Pratyush Yadav <me@yadavpratyush.com>
- Date
- Aug 6, 2019, 15:52 UTC
- Message-ID
- <b7cbe50d-879f-68b9-30b2-181c3058297f@yadavpratyush.com>
- In-Reply-To
- <20190804143919.10732-1-me@yadavpratyush.com>
If there are no comments/objections with this patch, can it be merged please?
On 8/4/19 8:09 PM, Pratyush Yadav wrote:
Show 43 quoted lines
> If the toplevel window for the window being destroyed is the main window
> (aka "."), then simply destroying it means the cleanup tasks are not
> executed like saving the commit message buffer, saving window state,
> etc. All this is handled by do_quit so, call it instead of directly
> destroying the main window. For other toplevel windows, the old behavior
> remains.
>
> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
> ---
> git-gui/git-gui.sh | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
> index 6de74ce639..6ec562d5da 100755
> --- a/git-gui/git-gui.sh
> +++ b/git-gui/git-gui.sh
> @@ -3030,8 +3030,23 @@ unset doc_path doc_url
> wm protocol . WM_DELETE_WINDOW do_quit
> bind all <$M1B-Key-q> do_quit
> bind all <$M1B-Key-Q> do_quit
> -bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
> -bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
> +
> +set m1b_w_script {
> + set toplvl_win [winfo toplevel %W]
> +
> + # If we are destroying the main window, we should call do_quit to take
> + # care of cleanup before exiting the program.
> + if {$toplvl_win eq "."} {
> + do_quit
> + } else {
> + destroy $toplvl_win
> + }
> +}
> +
> +bind all <$M1B-Key-w> $m1b_w_script
> +bind all <$M1B-Key-W> $m1b_w_script
> +
> +unset m1b_w_script
>
> set subcommand_args {}
> proc usage {} {
> -- Regards, Pratyush Yadav