Use wxDELETE() and wxDELETEA() when possible.
Use wxDELETE[A]() functions which automatically NULL out their arguments after deleting them instead of doing it manually. Closes #9685. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64656 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1949,8 +1949,7 @@ void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
if ( m_dlgReplace )
|
||||
{
|
||||
delete m_dlgReplace;
|
||||
m_dlgReplace = NULL;
|
||||
wxDELETE(m_dlgReplace);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1970,8 +1969,7 @@ void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
if ( m_dlgFind )
|
||||
{
|
||||
delete m_dlgFind;
|
||||
m_dlgFind = NULL;
|
||||
wxDELETE(m_dlgFind);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2147,9 +2145,7 @@ void MyModalDialog::OnButton(wxCommandEvent& event)
|
||||
{
|
||||
if ( event.GetEventObject() == m_btnDelete )
|
||||
{
|
||||
delete m_btnModal;
|
||||
m_btnModal = NULL;
|
||||
|
||||
wxDELETE(m_btnModal);
|
||||
m_btnDelete->Disable();
|
||||
}
|
||||
else if ( event.GetEventObject() == m_btnModal )
|
||||
|
@@ -265,8 +265,7 @@ void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
doc->Modify(true);
|
||||
}
|
||||
|
||||
delete m_currentSegment;
|
||||
m_currentSegment = NULL;
|
||||
wxDELETE(m_currentSegment);
|
||||
}
|
||||
|
||||
// is this the start of a new segment?
|
||||
|
@@ -135,8 +135,7 @@ void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
|
||||
m_dragImage->Hide();
|
||||
m_dragImage->EndDrag();
|
||||
delete m_dragImage;
|
||||
m_dragImage = NULL;
|
||||
wxDELETE(m_dragImage);
|
||||
|
||||
m_draggedShape->SetShow(true);
|
||||
|
||||
@@ -203,8 +202,7 @@ void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
|
||||
if (!m_dragImage->BeginDrag(beginDragHotSpot, this, fullScreen))
|
||||
{
|
||||
delete m_dragImage;
|
||||
m_dragImage = (wxDragImage*) NULL;
|
||||
wxDELETE(m_dragImage);
|
||||
m_dragMode = TEST_DRAG_NONE;
|
||||
|
||||
} else
|
||||
|
@@ -366,21 +366,13 @@ bool MyApp::OnInit()
|
||||
|
||||
void MyApp::DeleteBitmaps()
|
||||
{
|
||||
delete gs_bmpNoMask;
|
||||
delete gs_bmpWithColMask;
|
||||
delete gs_bmpMask;
|
||||
delete gs_bmpWithMask;
|
||||
delete gs_bmp4;
|
||||
delete gs_bmp4_mono;
|
||||
delete gs_bmp36;
|
||||
|
||||
gs_bmpNoMask = NULL;
|
||||
gs_bmpWithColMask = NULL;
|
||||
gs_bmpMask = NULL;
|
||||
gs_bmpWithMask = NULL;
|
||||
gs_bmp4 = NULL;
|
||||
gs_bmp4_mono = NULL;
|
||||
gs_bmp36 = NULL;
|
||||
wxDELETE(gs_bmpNoMask);
|
||||
wxDELETE(gs_bmpWithColMask);
|
||||
wxDELETE(gs_bmpMask);
|
||||
wxDELETE(gs_bmpWithMask);
|
||||
wxDELETE(gs_bmp4);
|
||||
wxDELETE(gs_bmp4_mono);
|
||||
wxDELETE(gs_bmp36);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -1370,8 +1370,7 @@ void MyPipeFrame::OnProcessTerm(wxProcessEvent& WXUNUSED(event))
|
||||
{
|
||||
DoGet();
|
||||
|
||||
delete m_process;
|
||||
m_process = NULL;
|
||||
wxDELETE(m_process);
|
||||
|
||||
wxLogWarning(wxT("The other process has terminated, closing"));
|
||||
|
||||
|
@@ -279,8 +279,7 @@ void MyFrame::OnWatch(wxCommandEvent& event)
|
||||
{
|
||||
wxCHECK_RET(m_watcher, "Watcher not initialized");
|
||||
m_filesList->DeleteAllItems();
|
||||
delete m_watcher;
|
||||
m_watcher = NULL;
|
||||
wxDELETE(m_watcher);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -223,8 +223,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
// frame destructor
|
||||
MyFrame::~MyFrame()
|
||||
{
|
||||
delete m_Prn;
|
||||
m_Prn = (wxHtmlEasyPrinting *) NULL;
|
||||
wxDELETE(m_Prn);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -184,8 +184,7 @@ void MyClient::Disconnect()
|
||||
if (m_connection)
|
||||
{
|
||||
m_connection->Disconnect();
|
||||
delete m_connection;
|
||||
m_connection = NULL;
|
||||
wxDELETE(m_connection);
|
||||
wxLogMessage("Client disconnected from server");
|
||||
}
|
||||
wxGetApp().ExitMainLoop();
|
||||
|
@@ -211,8 +211,7 @@ void MyServer::Disconnect()
|
||||
if ( m_connection )
|
||||
{
|
||||
m_connection->Disconnect();
|
||||
delete m_connection;
|
||||
m_connection = NULL;
|
||||
wxDELETE(m_connection);
|
||||
wxLogMessage("Disconnected client");
|
||||
}
|
||||
}
|
||||
|
@@ -234,8 +234,7 @@ void MyFrame::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
if (m_client)
|
||||
{
|
||||
delete m_client;
|
||||
m_client = NULL;
|
||||
wxDELETE(m_client);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
@@ -261,8 +260,7 @@ void MyFrame::OnStart(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
if (!retval)
|
||||
{
|
||||
delete m_client;
|
||||
m_client = NULL;
|
||||
wxDELETE(m_client);
|
||||
}
|
||||
EnableControls();
|
||||
}
|
||||
@@ -316,8 +314,7 @@ void MyFrame::OnDisconnect(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::Disconnect()
|
||||
{
|
||||
delete m_client;
|
||||
m_client = NULL;
|
||||
wxDELETE(m_client);
|
||||
EnableControls();
|
||||
}
|
||||
|
||||
@@ -399,8 +396,7 @@ void MyClient::Disconnect()
|
||||
if (m_connection)
|
||||
{
|
||||
m_connection->Disconnect();
|
||||
delete m_connection;
|
||||
m_connection = NULL;
|
||||
wxDELETE(m_connection);
|
||||
wxGetApp().GetFrame()->EnableControls();
|
||||
wxLogMessage(wxT("Client disconnected from server"));
|
||||
}
|
||||
|
@@ -160,11 +160,7 @@ void MyFrame::UpdateUI()
|
||||
|
||||
void MyFrame::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
if (m_server)
|
||||
{
|
||||
delete m_server;
|
||||
m_server = NULL;
|
||||
}
|
||||
wxDELETE(m_server);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
@@ -185,8 +181,7 @@ void MyFrame::OnStart(wxCommandEvent& WXUNUSED(event))
|
||||
else
|
||||
{
|
||||
wxLogMessage("Server %s failed to start", servername);
|
||||
delete m_server;
|
||||
m_server = NULL;
|
||||
wxDELETE(m_server);
|
||||
}
|
||||
UpdateUI();
|
||||
}
|
||||
@@ -262,8 +257,7 @@ void MyServer::Disconnect()
|
||||
{
|
||||
if ( m_connection )
|
||||
{
|
||||
delete m_connection;
|
||||
m_connection = NULL;
|
||||
wxDELETE(m_connection);
|
||||
wxGetApp().GetFrame()->UpdateUI();
|
||||
wxLogMessage("Disconnected client");
|
||||
}
|
||||
|
@@ -264,11 +264,7 @@ wxAdvImageFileProperty::wxAdvImageFileProperty( const wxString& label,
|
||||
wxAdvImageFileProperty::~wxAdvImageFileProperty ()
|
||||
{
|
||||
// Delete old image
|
||||
if ( m_pImage )
|
||||
{
|
||||
delete m_pImage;
|
||||
m_pImage = (wxImage*) NULL;
|
||||
}
|
||||
wxDELETE(m_pImage);
|
||||
}
|
||||
|
||||
void wxAdvImageFileProperty::OnSetValue()
|
||||
@@ -276,11 +272,7 @@ void wxAdvImageFileProperty::OnSetValue()
|
||||
wxFileProperty::OnSetValue();
|
||||
|
||||
// Delete old image
|
||||
if ( m_pImage )
|
||||
{
|
||||
delete m_pImage;
|
||||
m_pImage = (wxImage*) NULL;
|
||||
}
|
||||
wxDELETE(m_pImage);
|
||||
|
||||
wxString imagename = GetValueAsString(0);
|
||||
|
||||
@@ -398,11 +390,7 @@ void wxAdvImageFileProperty::LoadThumbnails( size_t index )
|
||||
|
||||
}
|
||||
|
||||
if ( m_pImage )
|
||||
{
|
||||
delete m_pImage;
|
||||
m_pImage = (wxImage*) NULL;
|
||||
}
|
||||
wxDELETE(m_pImage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1031,8 +1031,7 @@ void RegTreeCtrl::TreeNode::OnCollapse()
|
||||
{
|
||||
DestroyChildren();
|
||||
|
||||
delete m_pKey;
|
||||
m_pKey = NULL;
|
||||
wxDELETE(m_pKey);
|
||||
}
|
||||
|
||||
void RegTreeCtrl::TreeNode::Refresh()
|
||||
|
@@ -650,8 +650,7 @@ EventWorker::DoRead()
|
||||
if (m_size == m_infill)
|
||||
{
|
||||
m_signature[0] = m_signature[1] = 0x0;
|
||||
delete [] m_inbuf;
|
||||
m_inbuf = NULL;
|
||||
wxDELETEA(m_inbuf);
|
||||
m_infill = 0;
|
||||
return;
|
||||
}
|
||||
@@ -713,8 +712,7 @@ void EventWorker::DoWrite()
|
||||
{
|
||||
if (m_written == m_size)
|
||||
{
|
||||
delete [] m_outbuf;
|
||||
m_outbuf = NULL;
|
||||
wxDELETEA(m_outbuf);
|
||||
m_outfill = 0;
|
||||
LogWorker( "All data written");
|
||||
return;
|
||||
|
@@ -1002,8 +1002,7 @@ void MyFrame::OnSelectFile(wxCommandEvent& WXUNUSED(event))
|
||||
#endif // __WXMSW__
|
||||
m_useMemory = false;
|
||||
|
||||
delete m_sound;
|
||||
m_sound = NULL;
|
||||
wxDELETE(m_sound);
|
||||
NotifyUsingFile(m_soundFile);
|
||||
}
|
||||
#endif // wxUSE_FILEDLG
|
||||
@@ -1026,8 +1025,7 @@ void MyFrame::OnSelectResource(wxCommandEvent& WXUNUSED(event))
|
||||
m_soundFile.clear();
|
||||
m_useMemory = false;
|
||||
|
||||
delete m_sound;
|
||||
m_sound = NULL;
|
||||
wxDELETE(m_sound);
|
||||
|
||||
NotifyUsingFile(wxT("Windows WAV resource"));
|
||||
}
|
||||
|
@@ -682,17 +682,13 @@ AppAbout::AppAbout (wxWindow *parent,
|
||||
}
|
||||
|
||||
AppAbout::~AppAbout () {
|
||||
if (m_timer) {
|
||||
delete m_timer;
|
||||
m_timer = NULL;
|
||||
}
|
||||
wxDELETE(m_timer);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// event handlers
|
||||
void AppAbout::OnTimerEvent (wxTimerEvent &WXUNUSED(event)) {
|
||||
if (m_timer) delete m_timer;
|
||||
m_timer = NULL;
|
||||
wxDELETE(m_timer);
|
||||
EndModal (wxID_OK);
|
||||
}
|
||||
|
||||
|
@@ -725,8 +725,7 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( m_tbar )
|
||||
{
|
||||
delete m_tbar;
|
||||
m_tbar = NULL;
|
||||
wxDELETE(m_tbar);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -335,8 +335,7 @@ void GaugeWidgetsPage::StopTimer(wxButton *clicked)
|
||||
wxCHECK_RET( m_timer, wxT("shouldn't be called") );
|
||||
|
||||
m_timer->Stop();
|
||||
delete m_timer;
|
||||
m_timer = NULL;
|
||||
wxDELETE(m_timer);
|
||||
|
||||
if (clicked->GetId() == GaugePage_Progress)
|
||||
{
|
||||
|
@@ -335,11 +335,7 @@ void BookWidgetsPage::CreateImageList()
|
||||
}
|
||||
else // no images
|
||||
{
|
||||
if ( m_imageList )
|
||||
{
|
||||
delete m_imageList;
|
||||
m_imageList = NULL;
|
||||
}
|
||||
wxDELETE(m_imageList);
|
||||
}
|
||||
|
||||
// because of the bug in wxMSW we can't use SetImageList(NULL) - although
|
||||
|
@@ -115,8 +115,7 @@ void StatBmpWidgetsPage::CreateContent()
|
||||
|
||||
void StatBmpWidgetsPage::RecreateWidget()
|
||||
{
|
||||
delete m_statbmp;
|
||||
m_statbmp = NULL;
|
||||
wxDELETE(m_statbmp);
|
||||
|
||||
wxString filepath = m_filepicker->GetPath();
|
||||
if ( filepath.empty() )
|
||||
|
Reference in New Issue
Block a user