Mercurial > dwindows
changeset 1377:b6249d66404c
Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
when the ID is auto-generated. It is unsafe to do it for specified IDs because there
may be more than one menu item with an ID... however autogenerated IDs should be unique.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 23 Nov 2011 00:49:12 +0000 |
parents | 52bbb1acce61 |
children | a54720b10821 |
files | os2/dw.c win/dw.c |
diffstat | 2 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/os2/dw.c Tue Nov 22 22:20:39 2011 +0000 +++ b/os2/dw.c Wed Nov 23 00:49:12 2011 +0000 @@ -5222,9 +5222,12 @@ */ int API dw_menu_delete_item(HMENUI menux, unsigned long id) { - if(id < 65536) + if(id < 65536 && menux) { WinSendMsg(menux, MM_DELETEITEM, MPFROM2SHORT(id, FALSE), 0); + /* If the ID was autogenerated it is safe to remove it */ + if(id >= 30000) + dw_signal_disconnect_by_window((HWND)id); return DW_ERROR_NONE; } return DW_ERROR_UNKNOWN;
--- a/win/dw.c Tue Nov 22 22:20:39 2011 +0000 +++ b/win/dw.c Wed Nov 23 00:49:12 2011 +0000 @@ -5215,9 +5215,14 @@ if ( IsWindow(menux) && !IsMenu(mymenu) ) mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu"); - if ( DeleteMenu(mymenu, id, MF_BYCOMMAND) == 0 ) + if ( mymenu == 0 || DeleteMenu(mymenu, id, MF_BYCOMMAND) == 0 ) return DW_ERROR_UNKNOWN; + /* If the ID was autogenerated it is safe to remove it */ + if(id >= 30000) + dw_signal_disconnect_by_window((HWND)id); + + /* Make sure the menu is redrawn if needed */ if( (HMENU)menux != mymenu ) DrawMenuBar(menux); return DW_ERROR_NONE;