Fix a bug that KillMemView() calls multiple times to cause crash problems.

This commit is contained in:
owomomo 2020-10-05 19:12:47 +08:00
parent d4a8962695
commit d5ff6ff2fe
2 changed files with 12 additions and 15 deletions

View File

@ -1180,14 +1180,16 @@ void AutoScrollFromCoord(int x,int y)
void KillMemView()
{
ReleaseDC(hMemView,mDC);
DestroyWindow(hMemView);
UnregisterClass("MEMVIEW",fceu_hInstance);
hMemView = 0;
hMemFind = 0;
if (EditingMode == MODE_NES_MEMORY)
ReleaseCheatMap();
return;
if (hMemView)
{
ReleaseDC(hMemView, mDC);
DestroyWindow(hMemView);
UnregisterClass("MEMVIEW", fceu_hInstance);
hMemView = NULL;
hMemFind = NULL;
if (EditingMode == MODE_NES_MEMORY)
ReleaseCheatMap();
}
}
int GetMaxSize(int EditingMode)
@ -2485,10 +2487,6 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_CLOSE:
KillMemView();
//ReleaseDC (hwnd, mDC) ;
//DestroyWindow(hMemView);
//UnregisterClass("MEMVIEW",fceu_hInstance);
//hMemView = 0;
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;

View File

@ -338,7 +338,7 @@ int toggleBookmark(HWND hwnd, uint32 address, int editmode)
void updateBookmarkMenus(HMENU menu)
{
// Remove all bookmark menus
for (int i = 0; i<hexBookmarks.bookmarkCount + 1; i++)
for (int i = 0; i < hexBookmarks.bookmarkCount + 1; i++)
RemoveMenu(menu, ID_FIRST_BOOKMARK + i, MF_BYCOMMAND);
RemoveMenu(menu, ID_BOOKMARKLIST_SEP, MF_BYCOMMAND);
@ -346,7 +346,7 @@ void updateBookmarkMenus(HMENU menu)
{
// Add the menus again
InsertMenu(menu, ID_BOOKMARKS_IMPORT, MF_SEPARATOR | MF_BYCOMMAND, ID_BOOKMARKLIST_SEP, NULL);
for (int i = 0;i<hexBookmarks.bookmarkCount;i++)
for (int i = 0; i < hexBookmarks.bookmarkCount; i++)
{
// Get the text of the menu
char buffer[0x100];
@ -372,7 +372,6 @@ void updateBookmarkMenus(HMENU menu)
ModifyMenu(menu, ID_FIRST_BOOKMARK + hexBookmarks.shortcuts[i], MF_BYCOMMAND, ID_FIRST_BOOKMARK + hexBookmarks.shortcuts[i], buffer);
}
}
}
}