title: Dereferencing a pointer to a frame that doesn't exist anymore
body: <p>I have <code>MessagesViewer</code> frame that I want to control the uniqueness of,</p>
  
  <p>with this piece of code:</p>
  
  <pre><code>MessagesViewer* m_pMsgViewer = NULL;
  
  void Application::ShowMessagesViewer()
  {
      if (m_pMsgViewer == NULL)
      {
          m_pMsgViewer = new MessagesViewer(
              wxGetApp().GetContainer()-&gt;GetAppData()-&gt;GetMessages()
          );
      }
      else
      {
          m_pMsgViewer-&gt;FillPage(wxGetApp().GetContainer()-&gt;GetAppData()-&gt;GetMessages());
          m_pMsgViewer-&gt;SetFocus();
      }
  }
  </code></pre>
  
  <p>But when I call this for the first time, <code>m_pMsgViewer</code> starts to refer to valid data in the memory. When I close <code>MessagesViewer</code> frame, it destroys it automatically, but the pointer is still referencing to old address, and I can't control destroying the frame from this client code.</p>
  
  <p>How can I dereference a pointer to destroyed frame?</p>