]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed crash in text ctrl log on exit
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 21 Jul 2002 18:44:15 +0000 (18:44 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 21 Jul 2002 18:44:15 +0000 (18:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16239 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/text/text.cpp

index 8d902d230a02eaaad3e75807afba8b80d1f09944..03d6096f289a7b5b143f681a3dc8efb62c0dca53 100644 (file)
@@ -100,6 +100,7 @@ class MyPanel: public wxPanel
 {
 public:
     MyPanel(wxFrame *frame, int x, int y, int w, int h);
+    virtual ~MyPanel() { wxLog::SetActiveTarget(m_logOld); }
 
 #if wxUSE_CLIPBOARD
     void DoPasteFromClipboard();
@@ -126,6 +127,8 @@ public:
 
     wxTextCtrl    *m_log;
 
+    wxLog         *m_logOld;
+
 private:
     // get the currently focused text control or return the default one is no
     // text ctrl has focus
@@ -787,9 +790,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
                             wxPoint(5,260), wxSize(630,100),
                             wxTE_MULTILINE | wxTE_READONLY /* | wxTE_RICH */);
 
-    wxLog *old_log = wxLog::SetActiveTarget( new wxLogTextCtrl( m_log ) );
-
-    delete old_log;
+    m_logOld = wxLog::SetActiveTarget( new wxLogTextCtrl( m_log ) );
 
     // single line text controls
 
@@ -884,7 +885,6 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
                                 // wxTE_AUTO_URL |
                                 wxHSCROLL);
 
-#if 1
     m_textrich->SetStyle(0, 10, *wxRED);
     m_textrich->SetStyle(10, 20, *wxBLUE);
     m_textrich->SetStyle(30, 40,
@@ -899,16 +899,6 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     m_textrich->SetDefaultStyle(wxTextAttr(*wxBLUE, *wxWHITE));
     m_textrich->AppendText(_T("And this should be in blue and the text you ")
                            _T("type should be in blue as well"));
-#else
-    m_textrich->SetFont(wxFont(12, wxFONTFAMILY_TELETYPE,
-                               wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
-    m_textrich->SetDefaultStyle(wxTextAttr(*wxRED));
-    m_textrich->AppendText(_T("Red text\n"));
-    m_textrich->SetDefaultStyle(wxTextAttr(wxNullColour, *wxLIGHT_GREY));
-    m_textrich->AppendText(_T("Red on grey text\n"));
-    m_textrich->SetDefaultStyle(wxTextAttr(*wxBLUE));
-    m_textrich->AppendText(_T("Blue on grey text\n"));
-#endif
 }
 
 void MyPanel::OnSize( wxSizeEvent &event )