]> git.saurik.com Git - wxWidgets.git/commitdiff
fix crash if Delete menu command is used twice
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 4 Sep 2002 13:50:58 +0000 (13:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 4 Sep 2002 13:50:58 +0000 (13:50 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16969 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/config/conftest.cpp

index b85f46e015aa2bdc356dc0d7f2c153581e2dda51..2eedfb60dd2eb2b08443018c14f02f1c5a2b4539 100644 (file)
@@ -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"));
 }
+