comparison win/dw.c @ 1363:cdbe26a4b116

Mingw doesn't like writing to a compile time variable in dw_menu_append_item()... So make a temporary copy and do it there to prevent crashes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 18 Nov 2011 19:12:20 +0000
parents 412af8059331
children a595e368a393
comparison
equal deleted inserted replaced
1362:412af8059331 1363:cdbe26a4b116
4931 { 4931 {
4932 MENUITEMINFO mii; 4932 MENUITEMINFO mii;
4933 HMENU mymenu = (HMENU)menux; 4933 HMENU mymenu = (HMENU)menux;
4934 char buffer[31] = {0}; 4934 char buffer[31] = {0};
4935 int is_checked, is_disabled; 4935 int is_checked, is_disabled;
4936 char *menutitle = title;
4936 4937
4937 /* 4938 /*
4938 * Check if this is a menubar; if so get the menu object 4939 * Check if this is a menubar; if so get the menu object
4939 * for the menubar 4940 * for the menubar
4940 */ 4941 */
4946 mii.fMask = MIIM_ID | MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE; 4947 mii.fMask = MIIM_ID | MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
4947 4948
4948 /* Convert from OS/2 style accellerators to Win32 style */ 4949 /* Convert from OS/2 style accellerators to Win32 style */
4949 if (title) 4950 if (title)
4950 { 4951 {
4951 char *tmp = title; 4952 char *tmp = menutitle = _alloca(strlen(title)+1);
4953
4954 strcpy(tmp, title);
4952 4955
4953 while(*tmp) 4956 while(*tmp)
4954 { 4957 {
4955 if(*tmp == '~') 4958 if(*tmp == '~')
4956 *tmp = '&'; 4959 *tmp = '&';
4957 tmp++; 4960 tmp++;
4958 } 4961 }
4959 } 4962 }
4960 4963
4961 if (title && *title) 4964 if (menutitle && *menutitle)
4962 { 4965 {
4963 /* Code to autogenerate a menu ID if not specified or invalid 4966 /* Code to autogenerate a menu ID if not specified or invalid
4964 * First pool is smaller for transient popup menus 4967 * First pool is smaller for transient popup menus
4965 */ 4968 */
4966 if(id == (ULONG)-1) 4969 if(id == (ULONG)-1)
5009 mii.wID = id; 5012 mii.wID = id;
5010 if (IsMenu((HMENU)submenu)) 5013 if (IsMenu((HMENU)submenu))
5011 mii.hSubMenu = (HMENU)submenu; 5014 mii.hSubMenu = (HMENU)submenu;
5012 else 5015 else
5013 mii.hSubMenu = 0; 5016 mii.hSubMenu = 0;
5014 mii.dwTypeData = title; 5017 mii.dwTypeData = menutitle;
5015 mii.cch = strlen(title); 5018 mii.cch = strlen(menutitle);
5016 5019
5017 InsertMenuItem(mymenu, 65535, TRUE, &mii); 5020 InsertMenuItem(mymenu, 65535, TRUE, &mii);
5018 5021
5019 _snprintf(buffer, 30, "_dw_id%ld", id); 5022 _snprintf(buffer, 30, "_dw_id%ld", id);
5020 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)mymenu ); 5023 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)mymenu );