On Mon, Jan 19, 2009 at 12:21 PM, Bram Moolenaar <[email protected]> wrote:
> Ray Megal wrote:
>
>> gvim crashes when maximizing the window and using Ultramon's (3.0.4
>> beta) buttons.  I created the following patch against the latest
>> source but am unsure if it's the right way to handle this or how to go
>> about submitting it (I'm sure the instructions are somewhere but I
>> haven't found them-yet).
>>
>> I'm running on Vista Ultimate x64.
>>
>> This works for me but I'm wondering if using RegisterWindowMessage
>> instead of declaring WM_OLE = WM_APP+0 might be a better solution.
>> Anyone with more experience at this have an opinion?
>>
>> Patch follows:
>
> Weird problem, thanks for fixing it.
>
> To make sure Vim doesn't send an empty message I suggest a change to
> if_ole.cpp.  And we may also want to check for a NULL pointer.
>
> *** ../vim-7.2.084/src/if_ole.cpp       Sun Mar 16 14:53:11 2008
> --- src/if_ole.cpp      Mon Jan 19 21:16:33 2009
> ***************
> *** 353,361 ****
>      }
>
>      /* Pass the string to the main input loop. The memory will be freed when
> !      * the message is processed.
>       */
> !     PostMessage(NULL, WM_OLE, 0, (LPARAM)str);
>
>      return S_OK;
>  }
> --- 353,365 ----
>      }
>
>      /* Pass the string to the main input loop. The memory will be freed when
> !      * the message is processed.  Except for an empty message, we don't need
> !      * to post it then.
>       */
> !     if (*str == NUL)
> !       vim_free(str);
> !     else
> !       PostMessage(NULL, WM_OLE, 0, (LPARAM)str);
>
>      return S_OK;
>  }
> *** ../vim-7.2.084/src/gui_w48.c        Wed Dec 24 12:20:10 2008
> --- src/gui_w48.c       Mon Jan 19 21:19:30 2009
> ***************
> *** 1663,1670 ****
>      if (msg.message == WM_OLE)
>      {
>        char_u *str = (char_u *)msg.lParam;
> !       add_to_input_buf(str, (int)STRLEN(str));
> !       vim_free(str);
>        return;
>      }
>  #endif
> --- 1663,1679 ----
>      if (msg.message == WM_OLE)
>      {
>        char_u *str = (char_u *)msg.lParam;
> !       if (str == NULL || *str == NUL)
> !       {
> !           /* Message can't be ours, forward it.  Fixes problem with Ultramon
> !            * 3.0.4 */
> !           DispatchMessage(&msg);
> !       }
> !       else
> !       {
> !           add_to_input_buf(str, (int)STRLEN(str));
> !           vim_free(str);  /* was allocated in CVim::SendKeys() */
> !       }
>        return;
>      }
>  #endif

The patch looks good, though Ray's suggestion of RegisterWindowMessage
might be safer.

I'd argue, however, that the fault really lies with Ultramon. It's
supposed to unobtrusively hook into other processes. The WM_APP range
of messages has been documented as safe for applications to use for
their own private needs since the early 90s.
-- 
/George V. Reilly  [email protected]
http://www.georgevreilly.com/blog  http://blogs.cozi.com/tech

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui