| 459 | }; |
| 460 | |
| 461 | void MenuCreator::RebuildMenuBar() |
| 462 | { |
| 463 | auto &project = mProject; |
| 464 | // On OSX, we can't rebuild the menus while a modal dialog is being shown |
| 465 | // since the enabled state for menus like Quit and Preference gets out of |
| 466 | // sync with wxWidgets idea of what it should be. |
| 467 | #if defined(__WXMAC__) && defined(_DEBUG) |
| 468 | { |
| 469 | wxDialog *dlg = |
| 470 | wxDynamicCast(wxGetTopLevelParent(wxWindow::FindFocus()), wxDialog); |
| 471 | assert((!dlg || !dlg->IsModal())); |
| 472 | } |
| 473 | #endif |
| 474 | |
| 475 | // Delete the menus, since we will soon recreate them. |
| 476 | // Rather oddly, the menus don't vanish as a result of doing this. |
| 477 | { |
| 478 | auto &window = static_cast<wxFrameEx&>( GetProjectFrame( project ) ); |
| 479 | wxWindowPtr<wxMenuBar> menuBar{ window.GetMenuBar() }; |
| 480 | window.DetachMenuBar(); |
| 481 | // menuBar gets deleted here |
| 482 | } |
| 483 | |
| 484 | PurgeData(); |
| 485 | CreateMenusAndCommands(); |
| 486 | } |
| 487 | |
| 488 | constexpr auto JournalCode = wxT("CM"); // for CommandManager |
| 489 |
no test coverage detected