From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#49248: 28.0.50; read-from-minibuffer returns a window-live-p error when its original window is deleted Date: Thu, 01 Jul 2021 12:21:03 +0300 Message-ID: <83pmw2l79c.fsf@gnu.org> References: <8735t2h46e.fsf@posteo.net> <87a6na5ibc.fsf@posteo.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1971"; mail-complaints-to="usenet@ciao.gmane.io" Cc: thievol@posteo.net, 49248@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 01 11:23:54 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lysvK-0000MC-2v for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Jul 2021 11:23:54 +0200 Original-Received: from localhost ([::1]:37198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lysvJ-0001DO-0h for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Jul 2021 05:23:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lystW-0006GA-Cx for bug-gnu-emacs@gnu.org; Thu, 01 Jul 2021 05:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lystW-0002eG-48 for bug-gnu-emacs@gnu.org; Thu, 01 Jul 2021 05:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lystV-00034p-WB for bug-gnu-emacs@gnu.org; Thu, 01 Jul 2021 05:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Jul 2021 09:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49248 X-GNU-PR-Package: emacs Original-Received: via spool by 49248-submit@debbugs.gnu.org id=B49248.162513126811749 (code B ref 49248); Thu, 01 Jul 2021 09:22:01 +0000 Original-Received: (at 49248) by debbugs.gnu.org; 1 Jul 2021 09:21:08 +0000 Original-Received: from localhost ([127.0.0.1]:59563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyssd-00033P-Nz for submit@debbugs.gnu.org; Thu, 01 Jul 2021 05:21:07 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45148) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyssc-00032S-EE for 49248@debbugs.gnu.org; Thu, 01 Jul 2021 05:21:06 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:44854) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyssW-0001u5-QC; Thu, 01 Jul 2021 05:21:00 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1517 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyssW-0005Ht-2Z; Thu, 01 Jul 2021 05:21:00 -0400 In-Reply-To: (message from martin rudalics on Tue, 29 Jun 2021 10:03:11 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:209250 Archived-At: > From: martin rudalics > Date: Tue, 29 Jun 2021 10:03:11 +0200 > Cc: 49248@debbugs.gnu.org > > Apparently, exiting from the minibuffer may select a frame no less > than four times here: > > #1 in read_minibuf_unwind > if (!EQ (exp_MB_frame, saved_selected_frame) > && !NILP (exp_MB_frame)) > do_switch_frame (exp_MB_frame, 0, 0, Qt); /* This also sets > minibuf_window */ > > #2 in read_minibuf_unwind > else if (WINDOW_LIVE_P (calling_window)) > Fset_frame_selected_window (calling_frame, calling_window, Qnil); > > #3 in read_minibuf_unwind > /* Restore the selected frame. */ > if (!EQ (exp_MB_frame, saved_selected_frame) > && !NILP (exp_MB_frame)) > do_switch_frame (saved_selected_frame, 0, 0, Qt); > > #4 in read_minibuf > if (FRAMEP (calling_frame) > && FRAME_LIVE_P (XFRAME (calling_frame)) > && (!EQ (selected_frame, calling_frame) > || (WINDOW_LIVE_P (XFRAME (calling_frame)->minibuffer_window) > && !EQ (XWINDOW (XFRAME (calling_frame)->minibuffer_window) > ->frame, > calling_frame)))) > call2 (Qselect_frame_set_input_focus, calling_frame, Qnil); > > These will confuse the hell out of any window manager (and of me). Can > some knowledgeable soul tell us what all this code is supposed to do and > whether it could be refactored in some sane way? #1 and #3 are identical, so I think we could avoid #3 by testing the selected frame against saved_selected_frame. #2 is only done if "the previous minibuffer displayed in this miniwindow is dead", so I don't see a problem there. #4 is only done if read_minibuf_unwind didn't already do it, for whatever reason, so it's just the code trying to be defensive. (read_minibuf_unwind must re-select the original frame in case we QUIT or signal an error during read_minibuf.) HTH