From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: 'struct window' cleanup #5 [Re: 'struct window' cleanup #4] Date: Tue, 03 Jul 2012 18:58:40 +0300 Message-ID: <8362a46dlb.fsf@gnu.org> References: <4FF17BAE.7090200@yandex.ru> <83ehou5apu.fsf@gnu.org> <4FF28930.1000202@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1341331142 24298 80.91.229.3 (3 Jul 2012 15:59:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 3 Jul 2012 15:59:02 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 03 17:59:00 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sm5VD-00028M-MR for ged-emacs-devel@m.gmane.org; Tue, 03 Jul 2012 17:58:59 +0200 Original-Received: from localhost ([::1]:35802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm5VC-0005y9-MU for ged-emacs-devel@m.gmane.org; Tue, 03 Jul 2012 11:58:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm5V5-0005xk-8L for emacs-devel@gnu.org; Tue, 03 Jul 2012 11:58:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sm5Uy-00009o-IF for emacs-devel@gnu.org; Tue, 03 Jul 2012 11:58:50 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:49808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm5Uy-00009a-9f for emacs-devel@gnu.org; Tue, 03 Jul 2012 11:58:44 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0M6L00F00DN8NW00@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Tue, 03 Jul 2012 18:58:42 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.210.75]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M6L00FX7DPTET50@a-mtaout20.012.net.il>; Tue, 03 Jul 2012 18:58:42 +0300 (IDT) In-reply-to: <4FF28930.1000202@yandex.ru> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.166 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151394 Archived-At: > Date: Tue, 03 Jul 2012 09:54:56 +0400 > From: Dmitry Antipov > CC: emacs-devel@gnu.org > > > Shouldn't we test w->window_end_valid for being non-zero, before we > > trust the value of w->window_end_vpos? Zero for a vertical position > > is perfectly valid, so if i is zero, you can err here. > > The core idea is to have window_end_vpos (and window_end_pos) equal to -1 > for just created window (i.e. pointer returned by make_window). For such > a window, window_end_valid is always 0, and passing such a window to > main redisplay routines is an error (so there are 4 debugging checks > commented with "Just initialized windows should not pass here"). If the > window is completely initialized, window_end_vpos may be 0 and > window_end_valid may be 0 or 1. AFAICT, window_end_valid and window_end_vpos have nothing to do with initializing windows. They are flags used by the display engine in order to know when certain redisplay optimizations are possible. So I don't see how a completely initialized window has anything to do with the fact that window_end_vpos is valid. Am I missing something? But if what you write is true, the commentary to window_end_vpos and window_end_pos should be modified, because right now the comments tell explicitly not to trust the values of these two if window_end_valid is zero. If not every use of those two must test window_end_valid first, then we should explain in the comments when such a test is needed. > > Bother: doesn't the comparison with w->buffer test for a specific > > buffer, rather than just non-nil value? The corresponding assignment, > > viz.: > > > >> if (accurate_p) > >> { > >> - w->window_end_valid = w->buffer; > >> + w->window_end_valid = 1; > >> w->update_mode_line = 0; > >> } > > > > seems to handle the case when the display is "accurate". Perhaps use > > a different value, like 2, for this situation? > > I tried a lot, but never hits the situation where window buffer was changed > on the way from mark_window_display_accurate_1 to note_mouse_highlight (buffer > text may be changed, of course). So I suppose that w->window_end_valid = w->buffer > is just a synonym for w->window_end_valid = Qt. I'm not convinced, sorry. note_mouse_highlight is usually invoked asynchronously (when the mouse hovers above some mouse-sensitive part of the display), so deliberately producing a situation could be tricky. The fact that you didn't hit that combination doesn't necessarily prove it is impossible. So I would still suggest to use a special value, because bugs in these areas are notoriously hard to track down. Thanks.