Simon Clark
May 20th, 1998, 06:38 AM
I have found that the CCoolMenuManager class leaks memory in an application with a standard MFC MRU on the "File" menu. The "ConvertMenu" function continually allocates memory at the "pmd = new CMyItemData;" statement for the MRU items in the list everytime the menu drops down.
My guess is that when building the "File" menu, MFC dynamically removes the MRU items (causing the leak situation) before adding them to the list again.
A really quick fix is to put all of the code in the "if (bShowButtons) {" block statement inside another "if" statement like:-
if (info.wID = ID_FILE_MRU_FILE1 + _AFX_MRU_MAX_COUNT)
{
...
}
This cures the leak but fails to align the MRU list with the indented menu items in the rest of the "File" menu. The results are visually OK but if anyone else cares to suggest a better solution that aligns the text as well, then please do.
My guess is that when building the "File" menu, MFC dynamically removes the MRU items (causing the leak situation) before adding them to the list again.
A really quick fix is to put all of the code in the "if (bShowButtons) {" block statement inside another "if" statement like:-
if (info.wID = ID_FILE_MRU_FILE1 + _AFX_MRU_MAX_COUNT)
{
...
}
This cures the leak but fails to align the MRU list with the indented menu items in the rest of the "File" menu. The results are visually OK but if anyone else cares to suggest a better solution that aligns the text as well, then please do.