From aa03c83126225f92ec98569646b0d2aeffc45360 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Mon, 2 Dec 2019 20:40:48 +0000 Subject: [PATCH] pcsx2: Fix mainframe wxStaticBitmap delete issue wxWindow classes will delete their children when destroyed, so the wxStaticBitmap control must be allocated with new to avoid undefined behaviour. --- pcsx2/gui/MainFrame.cpp | 6 +++--- pcsx2/gui/MainFrame.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 4dc3aaea7c..f89a2e7b7a 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -327,7 +327,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) : wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxRESIZE_BORDER) ) , m_statusbar( *CreateStatusBar(2, 0) ) - , m_background( this, wxID_ANY, wxGetApp().GetLogoBitmap() ) + , m_background( new wxStaticBitmap(this, wxID_ANY, wxGetApp().GetLogoBitmap()) ) // All menu components must be created on the heap! @@ -382,7 +382,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) // The background logo and its window size are different on Windows. Use the // background logo size, which is what it'll eventually be resized to. - wxSize backsize(m_background.GetBitmap().GetWidth(), m_background.GetBitmap().GetHeight()); + wxSize backsize(m_background->GetBitmap().GetWidth(), m_background->GetBitmap().GetHeight()); wxString wintitle; if( PCSX2_isReleaseVersion ) @@ -416,7 +416,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) m_statusbar.SetStatusText( wxEmptyString, 0); wxBoxSizer& joe( *new wxBoxSizer( wxVERTICAL ) ); - joe.Add( &m_background ); + joe.Add( m_background ); SetSizerAndFit( &joe ); // Makes no sense, but this is needed for the window size to be correct for // 200% DPI on Windows. The SetSizerAndFit is supposed to be doing the exact diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index 4d4a398e8c..a8d9e562da 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -102,7 +102,7 @@ protected: bool m_RestartEmuOnDelete; wxStatusBar& m_statusbar; - wxStaticBitmap m_background; + wxStaticBitmap* m_background; wxMenuBar& m_menubar;