From: <kr_...@us...> - 2003-04-26 20:01:37
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv15274/port/src/cbits/Win32 Modified Files: Menu.c Log Message: bugfixes Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Menu.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Menu.c 23 Apr 2003 21:48:53 -0000 1.6 --- Menu.c 26 Apr 2003 20:01:33 -0000 1.7 *************** *** 403,431 **** pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - temp = malloc(strlen(title)+32); ! if (temp) { ! s = temp; ! while (*title) { ! if (*title != '\t') *s++ = *title; ! title++; } - *s = 0; - AddAccelString(handle->key, handle->mods, temp); - - memset(&mii,0,sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STRING; - mii.fType = MFT_STRING; - mii.dwTypeData = temp; - mii.cch = strlen(temp); - SetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); - - updateMenuBar(handle->parent); } ! ! free(temp); } --- 403,438 ---- pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! if (handle->parent == NULL) ! temp = title; ! else { ! temp = malloc(strlen(title)+32); ! if (!temp) ! temp = title; ! else { ! s = temp; ! while (*title) ! { ! if (*title != '\t') *s++ = *title; ! title++; ! } ! *s = 0; ! AddAccelString(handle->key, handle->mods, temp); } } ! ! memset(&mii,0,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STRING; ! mii.fType = MFT_STRING; ! mii.dwTypeData = temp; ! mii.cch = strlen(temp); ! SetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); ! ! updateMenuBar(handle->parent); ! ! if (temp != title) free(temp); } *************** *** 446,460 **** updateAccelTable(pFrameData->pMenuHandlesMap, handle, key, mods); ! memset(&mii,0,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STRING; ! mii.fType = MFT_STRING; ! mii.dwTypeData = NULL; ! mii.cch = 0; ! GetMenuItemInfo(hParent, pos, TRUE, &mii); ! mii.dwTypeData = malloc(mii.cch+32); ! ! if (mii.dwTypeData) { mii.cch++; GetMenuItemInfo(hParent, pos, TRUE, &mii); --- 453,470 ---- updateAccelTable(pFrameData->pMenuHandlesMap, handle, key, mods); ! if (handle->parent != NULL) { + memset(&mii,0,sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING; + mii.fType = MFT_STRING; + mii.dwTypeData = NULL; + mii.cch = 0; + GetMenuItemInfo(hParent, pos, TRUE, &mii); + mii.dwTypeData = malloc(mii.cch+32); + + if (!mii.dwTypeData) + return; + mii.cch++; GetMenuItemInfo(hParent, pos, TRUE, &mii); *************** *** 463,476 **** while (*s && *s != '\t') s++; *s = 0; ! AddAccelString(key, mods, s); mii.cch = strlen(mii.dwTypeData); SetMenuItemInfo(hParent, pos, TRUE, &mii); ! updateMenuBar(handle->parent); } - - free(mii.dwTypeData); } --- 473,486 ---- while (*s && *s != '\t') s++; *s = 0; ! AddAccelString(key, mods, s); mii.cch = strlen(mii.dwTypeData); SetMenuItemInfo(hParent, pos, TRUE, &mii); ! updateMenuBar(handle->parent); + + free(mii.dwTypeData); } } |