Patch 7.4.840

68 views
Skip to first unread message

Bram Moolenaar

unread,
Aug 26, 2015, 5:13:05 PM8/26/15
to vim...@googlegroups.com

Patch 7.4.840 (after 7.4.829)
Problem: Tooltip window stays open.
Solution: Send a WM_CLOSE message. (Jurgen Kramer)
Files: src/gui_w32.c


*** ../vim-7.4.839/src/gui_w32.c 2015-08-25 12:21:23.583957205 +0200
--- src/gui_w32.c 2015-08-26 23:10:03.847838259 +0200
***************
*** 4836,4841 ****
--- 4836,4842 ----
delete_tooltip(beval)
BalloonEval *beval;
{
+ PostMessage(beval->balloon, WM_CLOSE, 0, 0);
PostMessage(beval->balloon, WM_DESTROY, 0, 0);
PostMessage(beval->balloon, WM_NCDESTROY, 0, 0);
}
*** ../vim-7.4.839/src/version.c 2015-08-26 23:01:16.453676957 +0200
--- src/version.c 2015-08-26 23:11:28.262906177 +0200
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 840,
/**/

--
A programmer's wife asks him: "Please run to the store and pick up a loaf of
bread. If they have eggs, get a dozen". The programmer comes home with 12
loafs of bread.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yegappan Lakshmanan

unread,
Aug 26, 2015, 5:33:47 PM8/26/15
to vim_dev
Hi,

Based on the following posts:

http://blogs.msdn.com/b/oldnewthing/archive/2011/09/26/10216420.aspx
http://blogs.msdn.com/b/oldnewthing/archive/2005/07/27/443824.aspx

sending a WM_CLOSE and WM_NCDESTROY message to a window is not
the same as calling DestroyWindow(). So I think the original fix (patch 829)
for the crash is not correct.

- Yegappan

Raymond Ko

unread,
Aug 26, 2015, 8:15:26 PM8/26/15
to vim_dev

You might be right. If WM_CLOSE does eventually does internally call DestroyWindow() then the WM_DESTROY and WM_NCDESTROY might not be necessary. I wonder if there is a way to verify that this is the case? The main issue is that the code is crashing inside Microsoft's Common Controls DLL and I don't think the source code for this is accessible.

Yegappan Lakshmanan

unread,
Aug 27, 2015, 12:41:37 AM8/27/15
to vim_dev
Hi,
> You might be right. If WM_CLOSE does eventually does internally call
> DestroyWindow() then the WM_DESTROY and WM_NCDESTROY might not be necessary.
>

A WM_CLOSE message should be posted to a top level window to close
the window. In response to this message, the window event handler is supposed
to call the DestroyWindow() function. This function performs the following (as
described in the Microsoft documentation):

>>>>
Destroys the specified window. The function sends WM_DESTROY and WM_NCDESTROY
messages to the window to deactivate it and remove the keyboard focus from it.
The function also destroys the window's menu, flushes the thread message queue,
destroys timers, removes clipboard ownership, and breaks the clipboard viewer
chain (if the window is at the top of the viewer chain).
<<<<

The resources associated with the window are freed by the DestroyWindow()
function.

>
> I wonder if there is a way to verify that this is the case? The main issue is
> that the code is crashing inside Microsoft's Common Controls DLL and I don't
> think the source code for this is accessible.
>

Most probably it is crashing in the common controls DLL because Vim is
trying to use/access a window resource after it is freed/destroyed.

- Yegappan

Jürgen Krämer

unread,
Aug 27, 2015, 1:34:31 AM8/27/15
to vim...@googlegroups.com

Hi,

Yegappan Lakshmanan schrieb am 26.08.2015 um 23:33:
>
> Based on the following posts:
>
> http://blogs.msdn.com/b/oldnewthing/archive/2011/09/26/10216420.aspx
> http://blogs.msdn.com/b/oldnewthing/archive/2005/07/27/443824.aspx
>
> sending a WM_CLOSE and WM_NCDESTROY message to a window is not
> the same as calling DestroyWindow(). So I think the original fix (patch 829)
> for the crash is not correct.

if I understand the first post correctly it would be sufficient to only
send a WM_CLOSE message. For a test I removed the second and third calls
of PostMessage() and re-compiled. All balloon hints were cleanly removed
from the screen, but I could not check if there is a memory or resource
leak.

Patch attached.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
no-WM_DESTROY-for-ballon.patch

Charles Campbell

unread,
Sep 1, 2015, 11:02:33 AM9/1/15
to vim...@googlegroups.com
Bram Moolenaar wrote:
> Patch 7.4.840 (after 7.4.829)
> Problem: Tooltip window stays open.
> Solution: Send a WM_CLOSE message. (Jurgen Kramer)
> Files: src/gui_w32.c
>
>
> *** ../vim-7.4.839/src/gui_w32.c 2015-08-25 12:21:23.583957205 +0200
> --- src/gui_w32.c 2015-08-26 23:10:03.847838259 +0200
> ***************
> *** 4836,4841 ****
> --- 4836,4842 ----
> delete_tooltip(beval)
> BalloonEval *beval;
> {
> + PostMessage(beval->balloon, WM_CLOSE, 0, 0);
> PostMessage(beval->balloon, WM_DESTROY, 0, 0);
> PostMessage(beval->balloon, WM_NCDESTROY, 0, 0);
> }
> *** ../vim-7.4.839/src/version.c 2015-08-26 23:01:16.453676957 +0200
> --- src/version.c 2015-08-26 23:11:28.262906177 +0200
> ***************
> *** 743,744 ****
> --- 743,746 ----
> { /* Add new patch number below this line */
> + /**/
> + 840,
> /**/
>
While we're considering tooltip windows that stay open ...

I note that when having a tooltip window open in some file, then
switching workspaces (on a gtk-using linux box - scientific linux, so I
use ctrl-alt-arrow to change workspaces), the tooltip remains displayed
in the new workspace. Been that way forever, though -- its not some
artifact due to this patch or anything. Moving the mouse cursor about
in the new workspace doesn't clear the tooltip, either.

Regards,
Chip Campbell

Reply all
Reply to author
Forward
0 new messages