Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access violation when clearing recent files in File menu #317

Closed
Gumball2415 opened this issue Jan 7, 2025 · 1 comment · Fixed by #318
Closed

Access violation when clearing recent files in File menu #317

Gumball2415 opened this issue Jan 7, 2025 · 1 comment · Fixed by #318
Labels
bug Something isn't working crucial Resolve this as soon as possible

Comments

@Gumball2415
Copy link
Collaborator

issue originally from new_wub on ft.o discord server

version: Dn0.5.1.0 release

steps to reproduce:

  • File -> Recent Files -> Clear
  • confirm prompt
  • unhandled exception C0000005 occurs

image

@Gumball2415 Gumball2415 added the bug Something isn't working label Jan 7, 2025
@Gumball2415
Copy link
Collaborator Author

this bug has existed since Dn0.5.0.2, with the addition of the Export JSON option in the File menu.

void CFamiTrackerApp::OnRecentFilesClear() // // //
{
int confirm = AfxMessageBox(IDS_CLEAR_RECENTS, MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2);
if (confirm == IDNO) {
return;
} else if (confirm != IDYES) {
throw std::runtime_error("Recent Files Clear message box returned invalid value");
}
SAFE_RELEASE(m_pRecentFileList);
m_pRecentFileList = new CRecentFileList(0, _T("Recent File List"), _T("File%d"), MAX_RECENT_FILES);
auto pMenu = m_pMainWnd->GetMenu()->GetSubMenu(0)->GetSubMenu(14);
for (int i = 0; i < MAX_RECENT_FILES; ++i)
pMenu->RemoveMenu(ID_FILE_MRU_FILE1 + i, MF_BYCOMMAND);
pMenu->AppendMenu(MF_STRING, ID_FILE_MRU_FILE1, _T("(File)"));
}

the program indexes into the Recent Files submenu with hardcoded numbers. thus, when it tries to assign the pointer to 14th item in the Files menu to pMenu (the separator before Recent Files), it returns nullptr, and crashes on the member function RemoveMenu().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crucial Resolve this as soon as possible
Projects
None yet
1 participant