From 798265916e61ca10a0f5552353a57c7ac9d50b61 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 4 Sep 2002 13:50:58 +0000 Subject: [PATCH] fix crash if Delete menu command is used twice git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16969 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/config/conftest.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/samples/config/conftest.cpp b/samples/config/conftest.cpp index b85f46e015..2eedfb60dd 100644 --- a/samples/config/conftest.cpp +++ b/samples/config/conftest.cpp @@ -220,11 +220,18 @@ void MyFrame::OnAbout(wxCommandEvent&) void MyFrame::OnDelete(wxCommandEvent&) { - if ( wxConfigBase::Get()->DeleteAll() ) + wxConfigBase *pConfig = wxConfigBase::Get(); + if ( pConfig == NULL ) + { + wxLogError(_T("No config to delete!")); + return; + } + + if ( pConfig->DeleteAll() ) { wxLogMessage(_T("Config file/registry key successfully deleted.")); - delete wxConfigBase::Set((wxConfigBase *) NULL); + delete wxConfigBase::Set(NULL); wxConfigBase::DontCreateOnDemand(); } else @@ -235,10 +242,11 @@ void MyFrame::OnDelete(wxCommandEvent&) MyFrame::~MyFrame() { - // save the control's values to the config wxConfigBase *pConfig = wxConfigBase::Get(); if ( pConfig == NULL ) return; + + // save the control's values to the config pConfig->Write("/Controls/Text", m_text->GetValue()); pConfig->Write("/Controls/Check", m_check->GetValue()); @@ -253,3 +261,4 @@ MyFrame::~MyFrame() pConfig->Write("/TestValue", wxT("A test value")); } + -- 2.47.2