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() void KillMemView()
{ {
ReleaseDC(hMemView,mDC); if (hMemView)
{
ReleaseDC(hMemView, mDC);
DestroyWindow(hMemView); DestroyWindow(hMemView);
UnregisterClass("MEMVIEW",fceu_hInstance); UnregisterClass("MEMVIEW", fceu_hInstance);
hMemView = 0; hMemView = NULL;
hMemFind = 0; hMemFind = NULL;
if (EditingMode == MODE_NES_MEMORY) if (EditingMode == MODE_NES_MEMORY)
ReleaseCheatMap(); ReleaseCheatMap();
return; }
} }
int GetMaxSize(int EditingMode) int GetMaxSize(int EditingMode)
@ -2485,10 +2487,6 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_CLOSE: case WM_CLOSE:
KillMemView(); KillMemView();
//ReleaseDC (hwnd, mDC) ;
//DestroyWindow(hMemView);
//UnregisterClass("MEMVIEW",fceu_hInstance);
//hMemView = 0;
return 0; return 0;
} }
return DefWindowProc (hwnd, message, wParam, lParam) ; return DefWindowProc (hwnd, message, wParam, lParam) ;

View File

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