user32: Use a finally handler to make sure capture is always released when exiting the menu loop.

This commit is contained in:
Alexandre Julliard 2009-01-26 15:08:49 +01:00
parent 58010a9750
commit f12c5bfca3
1 changed files with 8 additions and 3 deletions

View File

@ -56,6 +56,7 @@
#include "wownt32.h" #include "wownt32.h"
#include "wine/server.h" #include "wine/server.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/exception.h"
#include "win.h" #include "win.h"
#include "controls.h" #include "controls.h"
#include "user_private.h" #include "user_private.h"
@ -2964,6 +2965,11 @@ static void MENU_KeyRight( MTRACKER* pmt, UINT wFlags )
} }
} }
static void CALLBACK release_capture( BOOL __normal )
{
set_capture_window( 0, GUI_INMENUMODE, NULL );
}
/*********************************************************************** /***********************************************************************
* MENU_TrackMenu * MENU_TrackMenu
* *
@ -3011,7 +3017,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
capture_win = (wFlags & TPM_POPUPMENU) ? menu->hWnd : mt.hOwnerWnd; capture_win = (wFlags & TPM_POPUPMENU) ? menu->hWnd : mt.hOwnerWnd;
set_capture_window( capture_win, GUI_INMENUMODE, NULL ); set_capture_window( capture_win, GUI_INMENUMODE, NULL );
while (!fEndMenu) __TRY while (!fEndMenu)
{ {
menu = MENU_GetMenu( mt.hCurrentMenu ); menu = MENU_GetMenu( mt.hCurrentMenu );
if (!menu) /* sometimes happens if I do a window manager close */ if (!menu) /* sometimes happens if I do a window manager close */
@ -3232,8 +3238,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ); PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
else mt.trackFlags &= ~TF_SKIPREMOVE; else mt.trackFlags &= ~TF_SKIPREMOVE;
} }
__FINALLY( release_capture )
set_capture_window( 0, GUI_INMENUMODE, NULL );
/* If dropdown is still painted and the close box is clicked on /* If dropdown is still painted and the close box is clicked on
then the menu will be destroyed as part of the DispatchMessage above. then the menu will be destroyed as part of the DispatchMessage above.