Fix render to main crashing in fullscreen.

When hiding the menubar (for going fullscreen with render to main),
keep a functionally-duplicate menubar around for servicing menubar
actions.
This commit is contained in:
Shawn Hoffman
2014-09-05 22:15:10 -07:00
parent 387e1e3f21
commit 7308b809d8
3 changed files with 38 additions and 18 deletions

View File

@ -108,13 +108,24 @@ extern "C" {
class InputConfig;
class wxFrame;
// This override allows returning a fake menubar object while removing the real one from the screen
wxMenuBar* CFrame::GetMenuBar() const
{
if (m_frameMenuBar)
{
return m_frameMenuBar;
}
else
{
return m_menubar_shadow;
}
}
// Create menu items
// ---------------------
void CFrame::CreateMenu()
wxMenuBar* CFrame::CreateMenu()
{
if (GetMenuBar()) GetMenuBar()->Destroy();
wxMenuBar *m_MenuBar = new wxMenuBar();
wxMenuBar* menubar = new wxMenuBar();
// file menu
wxMenu* fileMenu = new wxMenu;
@ -137,7 +148,7 @@ void CFrame::CreateMenu()
fileMenu->Append(IDM_BROWSE, _("&Browse for ISOs..."));
fileMenu->AppendSeparator();
fileMenu->Append(wxID_EXIT, _("E&xit") + wxString("\tAlt+F4"));
m_MenuBar->Append(fileMenu, _("&File"));
menubar->Append(fileMenu, _("&File"));
// Emulation menu
wxMenu* emulationMenu = new wxMenu;
@ -197,7 +208,7 @@ void CFrame::CreateMenu()
for (unsigned int i = 1; i <= State::NUM_STATES; i++)
loadMenu->Append(IDM_LOADLAST1 + i - 1, GetMenuLabel(HK_LOAD_LAST_STATE_1 + i - 1));
m_MenuBar->Append(emulationMenu, _("&Emulation"));
menubar->Append(emulationMenu, _("&Emulation"));
// Options menu
wxMenu* pOptionsMenu = new wxMenu;
@ -213,7 +224,7 @@ void CFrame::CreateMenu()
pOptionsMenu->AppendSeparator();
g_pCodeWindow->CreateMenuOptions(pOptionsMenu);
}
m_MenuBar->Append(pOptionsMenu, _("&Options"));
menubar->Append(pOptionsMenu, _("&Options"));
// Tools menu
wxMenu* toolsMenu = new wxMenu;
@ -236,7 +247,7 @@ void CFrame::CreateMenu()
toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE4, GetMenuLabel(HK_WIIMOTE4_CONNECT));
toolsMenu->AppendCheckItem(IDM_CONNECT_BALANCEBOARD, GetMenuLabel(HK_BALANCEBOARD_CONNECT));
m_MenuBar->Append(toolsMenu, _("&Tools"));
menubar->Append(toolsMenu, _("&Tools"));
wxMenu* viewMenu = new wxMenu;
viewMenu->AppendCheckItem(IDM_TOGGLE_TOOLBAR, _("Show &Toolbar"));
@ -326,11 +337,11 @@ void CFrame::CreateMenu()
m_MenuBar->Append(viewMenu, _("&View"));
menubar->Append(viewMenu, _("&View"));
if (g_pCodeWindow)
{
g_pCodeWindow->CreateMenu(SConfig::GetInstance().m_LocalCoreStartupParameter, m_MenuBar);
g_pCodeWindow->CreateMenu(SConfig::GetInstance().m_LocalCoreStartupParameter, menubar);
}
// Help menu
@ -342,10 +353,9 @@ void CFrame::CreateMenu()
helpMenu->Append(IDM_HELPGITHUB, _("Dolphin at &GitHub"));
helpMenu->AppendSeparator();
helpMenu->Append(wxID_ABOUT, _("&About..."));
m_MenuBar->Append(helpMenu, _("&Help"));
menubar->Append(helpMenu, _("&Help"));
// Associate the menu bar with the frame
SetMenuBar(m_MenuBar);
return menubar;
}
wxString CFrame::GetMenuLabel(int Id)