Karsten Hopp 85dd58
To: vim_dev@googlegroups.com
Karsten Hopp 85dd58
Subject: Patch 7.3.306
Karsten Hopp 85dd58
Fcc: outbox
Karsten Hopp 85dd58
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 85dd58
Mime-Version: 1.0
Karsten Hopp 85dd58
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 85dd58
Content-Transfer-Encoding: 8bit
Karsten Hopp 85dd58
------------
Karsten Hopp 85dd58
Karsten Hopp 85dd58
Patch 7.3.306
Karsten Hopp 85dd58
Problem:    When closing a window there is a chance that deleting a scrollbar
Karsten Hopp 85dd58
	    triggers a GUI resize, which uses the window while it is not in a
Karsten Hopp 85dd58
	    valid state.
Karsten Hopp 85dd58
Solution:   Set the buffer pointer to NULL to be able to detect the invalid
Karsten Hopp 85dd58
	    situation.  Fix a few places that used the buffer pointer
Karsten Hopp 85dd58
	    incorrectly.
Karsten Hopp 85dd58
Files:	    src/buffer.c, src/ex_cmds.c, src/term.c, src/window.c
Karsten Hopp 85dd58
Karsten Hopp 85dd58
Karsten Hopp 85dd58
*** ../vim-7.3.305/src/buffer.c	2011-05-19 13:40:47.000000000 +0200
Karsten Hopp 85dd58
--- src/buffer.c	2011-09-10 13:46:59.000000000 +0200
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 416,421 ****
Karsten Hopp 85dd58
--- 416,423 ----
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
      buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0));
Karsten Hopp 85dd58
+     if (win_valid(win) && win->w_buffer == buf)
Karsten Hopp 85dd58
+ 	win->w_buffer = NULL;  /* make sure we don't use the buffer now */
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
  #ifdef FEAT_AUTOCMD
Karsten Hopp 85dd58
      /* Autocommands may have deleted the buffer. */
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 560,565 ****
Karsten Hopp 85dd58
--- 562,571 ----
Karsten Hopp 85dd58
  #ifdef FEAT_DIFF
Karsten Hopp 85dd58
      diff_buf_delete(buf);	    /* Can't use 'diff' for unloaded buffer. */
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
+ #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
+     if (curwin->w_buffer == buf)
Karsten Hopp 85dd58
+ 	reset_synblock(curwin);	    /* remove any ownsyntax */
Karsten Hopp 85dd58
+ #endif
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
  #ifdef FEAT_FOLDING
Karsten Hopp 85dd58
      /* No folds in an empty buffer. */
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 1346,1351 ****
Karsten Hopp 85dd58
--- 1352,1361 ----
Karsten Hopp 85dd58
  # endif
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
      {
Karsten Hopp 85dd58
+ #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
+ 	if (prevbuf == curwin->w_buffer)
Karsten Hopp 85dd58
+ 	    reset_synblock(curwin);
Karsten Hopp 85dd58
+ #endif
Karsten Hopp 85dd58
  #ifdef FEAT_WINDOWS
Karsten Hopp 85dd58
  	if (unload)
Karsten Hopp 85dd58
  	    close_windows(prevbuf, FALSE);
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 1395,1404 ****
Karsten Hopp 85dd58
      foldUpdateAll(curwin);	/* update folds (later). */
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
- #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
-     reset_synblock(curwin);
Karsten Hopp 85dd58
-     curwin->w_s = &(buf->b_s);
Karsten Hopp 85dd58
- #endif
Karsten Hopp 85dd58
      /* Get the buffer in the current window. */
Karsten Hopp 85dd58
      curwin->w_buffer = buf;
Karsten Hopp 85dd58
      curbuf = buf;
Karsten Hopp 85dd58
--- 1405,1410 ----
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 1409,1414 ****
Karsten Hopp 85dd58
--- 1415,1424 ----
Karsten Hopp 85dd58
  	diff_buf_add(curbuf);
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
+ #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
+     curwin->w_s = &(buf->b_s);
Karsten Hopp 85dd58
+ #endif
Karsten Hopp 85dd58
+ 
Karsten Hopp 85dd58
      /* Cursor on first line by default. */
Karsten Hopp 85dd58
      curwin->w_cursor.lnum = 1;
Karsten Hopp 85dd58
      curwin->w_cursor.col = 0;
Karsten Hopp 85dd58
*** ../vim-7.3.305/src/ex_cmds.c	2011-07-07 16:20:45.000000000 +0200
Karsten Hopp 85dd58
--- src/ex_cmds.c	2011-09-10 13:39:13.000000000 +0200
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 3619,3628 ****
Karsten Hopp 85dd58
       */
Karsten Hopp 85dd58
      check_arg_idx(curwin);
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
- #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
-     reset_synblock(curwin);	    /* remove any ownsyntax */
Karsten Hopp 85dd58
- #endif
Karsten Hopp 85dd58
- 
Karsten Hopp 85dd58
  #ifdef FEAT_AUTOCMD
Karsten Hopp 85dd58
      if (!auto_buf)
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
--- 3619,3624 ----
Karsten Hopp 85dd58
*** ../vim-7.3.305/src/term.c	2011-05-10 16:41:13.000000000 +0200
Karsten Hopp 85dd58
--- src/term.c	2011-09-14 14:39:39.000000000 +0200
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 3017,3028 ****
Karsten Hopp 85dd58
      if (width < 0 || height < 0)    /* just checking... */
Karsten Hopp 85dd58
  	return;
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
!     if (State == HITRETURN || State == SETWSIZE) /* postpone the resizing */
Karsten Hopp 85dd58
      {
Karsten Hopp 85dd58
  	State = SETWSIZE;
Karsten Hopp 85dd58
  	return;
Karsten Hopp 85dd58
      }
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
      ++busy;
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
  #ifdef AMIGA
Karsten Hopp 85dd58
--- 3017,3036 ----
Karsten Hopp 85dd58
      if (width < 0 || height < 0)    /* just checking... */
Karsten Hopp 85dd58
  	return;
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
!     if (State == HITRETURN || State == SETWSIZE)
Karsten Hopp 85dd58
      {
Karsten Hopp 85dd58
+ 	/* postpone the resizing */
Karsten Hopp 85dd58
  	State = SETWSIZE;
Karsten Hopp 85dd58
  	return;
Karsten Hopp 85dd58
      }
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
+     /* curwin->w_buffer can be NULL when we are closing a window and the
Karsten Hopp 85dd58
+      * buffer has already been closed and removing a scrollbar causes a resize
Karsten Hopp 85dd58
+      * event. Don't resize then, it will happen after entering another buffer.
Karsten Hopp 85dd58
+      */
Karsten Hopp 85dd58
+     if (curwin->w_buffer == NULL)
Karsten Hopp 85dd58
+ 	return;
Karsten Hopp 85dd58
+ 
Karsten Hopp 85dd58
      ++busy;
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
  #ifdef AMIGA
Karsten Hopp 85dd58
*** ../vim-7.3.305/src/window.c	2011-01-08 14:45:57.000000000 +0100
Karsten Hopp 85dd58
--- src/window.c	2011-09-10 14:04:56.000000000 +0200
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 1226,1240 ****
Karsten Hopp 85dd58
      }
Karsten Hopp 85dd58
      newp->w_tagstackidx = oldp->w_tagstackidx;
Karsten Hopp 85dd58
      newp->w_tagstacklen = oldp->w_tagstacklen;
Karsten Hopp 85dd58
! # ifdef FEAT_FOLDING
Karsten Hopp 85dd58
      copyFoldingState(oldp, newp);
Karsten Hopp 85dd58
! # endif
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
      win_init_some(newp, oldp);
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
! # ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
      check_colorcolumn(newp);
Karsten Hopp 85dd58
! # endif
Karsten Hopp 85dd58
  }
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
  /*
Karsten Hopp 85dd58
--- 1226,1240 ----
Karsten Hopp 85dd58
      }
Karsten Hopp 85dd58
      newp->w_tagstackidx = oldp->w_tagstackidx;
Karsten Hopp 85dd58
      newp->w_tagstacklen = oldp->w_tagstacklen;
Karsten Hopp 85dd58
! #ifdef FEAT_FOLDING
Karsten Hopp 85dd58
      copyFoldingState(oldp, newp);
Karsten Hopp 85dd58
! #endif
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
      win_init_some(newp, oldp);
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
! #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
      check_colorcolumn(newp);
Karsten Hopp 85dd58
! #endif
Karsten Hopp 85dd58
  }
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
  /*
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 2212,2217 ****
Karsten Hopp 85dd58
--- 2212,2222 ----
Karsten Hopp 85dd58
  	out_flush();
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
+ #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
+     /* Free independent synblock before the buffer is freed. */
Karsten Hopp 85dd58
+     reset_synblock(win);
Karsten Hopp 85dd58
+ #endif
Karsten Hopp 85dd58
+ 
Karsten Hopp 85dd58
      /*
Karsten Hopp 85dd58
       * Close the link to the buffer.
Karsten Hopp 85dd58
       */
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 2222,2228 ****
Karsten Hopp 85dd58
      if (!win_valid(win) || last_window() || curtab != prev_curtab)
Karsten Hopp 85dd58
  	return;
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
!     /* Free the memory used for the window. */
Karsten Hopp 85dd58
      wp = win_free_mem(win, &dir, NULL);
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
      /* Make sure curwin isn't invalid.  It can cause severe trouble when
Karsten Hopp 85dd58
--- 2227,2234 ----
Karsten Hopp 85dd58
      if (!win_valid(win) || last_window() || curtab != prev_curtab)
Karsten Hopp 85dd58
  	return;
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
!     /* Free the memory used for the window and get the window that received
Karsten Hopp 85dd58
!      * the screen space. */
Karsten Hopp 85dd58
      wp = win_free_mem(win, &dir, NULL);
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
      /* Make sure curwin isn't invalid.  It can cause severe trouble when
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 3247,3252 ****
Karsten Hopp 85dd58
--- 3253,3261 ----
Karsten Hopp 85dd58
      else
Karsten Hopp 85dd58
  	wp->w_farsi = W_CONV;
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
+ #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
+     wp->w_s = &wp->w_buffer->b_s;
Karsten Hopp 85dd58
+ #endif
Karsten Hopp 85dd58
  }
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
  /*
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 4437,4443 ****
Karsten Hopp 85dd58
  #endif /* FEAT_GUI */
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
  #ifdef FEAT_SYN_HL
Karsten Hopp 85dd58
-     reset_synblock(wp);  /* free independent synblock */
Karsten Hopp 85dd58
      vim_free(wp->w_p_cc_cols);
Karsten Hopp 85dd58
  #endif
Karsten Hopp 85dd58
  
Karsten Hopp 85dd58
--- 4446,4451 ----
Karsten Hopp 85dd58
*** ../vim-7.3.305/src/version.c	2011-09-14 14:33:47.000000000 +0200
Karsten Hopp 85dd58
--- src/version.c	2011-09-14 14:35:30.000000000 +0200
Karsten Hopp 85dd58
***************
Karsten Hopp 85dd58
*** 711,712 ****
Karsten Hopp 85dd58
--- 711,714 ----
Karsten Hopp 85dd58
  {   /* Add new patch number below this line */
Karsten Hopp 85dd58
+ /**/
Karsten Hopp 85dd58
+     306,
Karsten Hopp 85dd58
  /**/
Karsten Hopp 85dd58
Karsten Hopp 85dd58
-- 
Karsten Hopp 85dd58
A consultant is a person who takes your money and annoys your employees while
Karsten Hopp 85dd58
tirelessly searching for the best way to extend the consulting contract.
Karsten Hopp 85dd58
				(Scott Adams - The Dilbert principle)
Karsten Hopp 85dd58
Karsten Hopp 85dd58
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 85dd58
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 85dd58
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 85dd58
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///