diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 7885986fb2..5a2c09b7fd 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -318,7 +318,7 @@ CFrame::CFrame(wxFrame* parent, long style) : CRenderFrame(parent, id, title, pos, size, style) , g_pCodeWindow(nullptr), g_NetPlaySetupDiag(nullptr), g_CheatsWindow(nullptr) - , m_SavedPerspectives(nullptr), m_ToolBar(nullptr) + , m_menubar_shadow(nullptr), m_SavedPerspectives(nullptr), m_ToolBar(nullptr) , m_GameListCtrl(nullptr), m_Panel(nullptr) , m_RenderFrame(nullptr), m_RenderParent(nullptr) , m_LogWindow(nullptr), m_LogConfigWindow(nullptr) @@ -353,7 +353,10 @@ CFrame::CFrame(wxFrame* parent, GetStatusBar()->Hide(); // Give it a menu bar - CreateMenu(); + wxMenuBar* menubar_active = CreateMenu(); + SetMenuBar(menubar_active); + // Create a menubar to service requests while the real menubar is hidden from the screen + m_menubar_shadow = CreateMenu(); // --------------- // Main panel @@ -450,6 +453,10 @@ CFrame::~CFrame() ClosePages(); delete m_Mgr; + + // This object is owned by us, not wxw + m_menubar_shadow->Destroy(); + m_menubar_shadow = nullptr; } bool CFrame::RendererIsFullscreen() @@ -1271,9 +1278,9 @@ void CFrame::DoFullscreen(bool enable_fullscreen) DoToggleToolbar(SConfig::GetInstance().m_InterfaceToolbar); // Recreate the menubar if needed. - if (GetMenuBar() == nullptr) + if (wxFrame::GetMenuBar() == nullptr) { - CreateMenu(); + SetMenuBar(CreateMenu()); } // Show statusbar if enabled diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index 1ca67caa5e..8a53df5783 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -129,6 +129,7 @@ public: void UpdateTitle(const std::string &str); const CGameListCtrl *GetGameListCtrl() const; + virtual wxMenuBar* GetMenuBar() const override; #ifdef __WXGTK__ Common::Event panic_event; @@ -199,9 +200,11 @@ private: wxBitmap m_Bitmaps[EToolbar_Max]; wxBitmap m_BitmapsMenu[EToolbar_Max]; + wxMenuBar* m_menubar_shadow; + void PopulateToolbar(wxToolBar* toolBar); void RecreateToolbar(); - void CreateMenu(); + wxMenuBar* CreateMenu(); // Utility wxString GetMenuLabel(int Id); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 7341e62336..489c835baf 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -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)