From 5276b0a53cef4815230e39b54d2ecda14f72cbd1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 20 Jun 2010 18:18:23 +0000 Subject: [PATCH] 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 --- samples/dialogs/dialogs.cpp | 10 +++------- samples/docview/view.cpp | 3 +-- samples/dragimag/dragimag.cpp | 6 ++---- samples/drawing/drawing.cpp | 22 +++++++--------------- samples/exec/exec.cpp | 3 +-- samples/fswatcher/fswatcher.cpp | 3 +-- samples/html/printing/printing.cpp | 3 +-- samples/ipc/baseclient.cpp | 3 +-- samples/ipc/baseserver.cpp | 3 +-- samples/ipc/client.cpp | 12 ++++-------- samples/ipc/server.cpp | 12 +++--------- samples/propgrid/propgrid.cpp | 18 +++--------------- samples/regtest/regtest.cpp | 3 +-- samples/sockets/baseserver.cpp | 6 ++---- samples/sound/sound.cpp | 6 ++---- samples/stc/stctest.cpp | 8 ++------ samples/toolbar/toolbar.cpp | 3 +-- samples/widgets/gauge.cpp | 3 +-- samples/widgets/notebook.cpp | 6 +----- samples/widgets/statbmp.cpp | 3 +-- src/cocoa/fontutil.cpp | 4 +--- src/common/any.cpp | 3 +-- src/common/appbase.cpp | 9 ++------- src/common/appcmn.cpp | 3 +-- src/common/artprov.cpp | 7 ++----- src/common/cmndata.cpp | 12 ++---------- src/common/combocmn.cpp | 11 ++++------- src/common/dlgcmn.cpp | 3 +-- src/common/docview.cpp | 3 +-- src/common/dpycmn.cpp | 6 +----- src/common/dynload.cpp | 3 +-- src/common/encconv.cpp | 2 +- src/common/event.cpp | 3 +-- src/common/fileback.cpp | 12 ++++-------- src/common/framecmn.cpp | 18 +++--------------- src/common/fs_arc.cpp | 6 ++---- src/common/ftp.cpp | 3 +-- src/common/gdicmn.cpp | 3 +-- src/common/hash.cpp | 4 +--- src/common/http.cpp | 6 ++---- src/common/imagiff.cpp | 15 +++++---------- src/common/init.cpp | 3 +-- src/common/intl.cpp | 3 +-- src/common/mediactrlcmn.cpp | 6 ++---- src/common/mimecmn.cpp | 3 +-- src/common/object.cpp | 3 +-- src/common/paper.cpp | 3 +-- src/common/radiocmn.cpp | 3 +-- src/common/regex.cpp | 3 +-- src/common/socket.cpp | 6 ++---- src/common/strconv.cpp | 3 +-- src/common/url.cpp | 6 ++---- src/common/utilscmn.cpp | 3 +-- src/common/wincmn.cpp | 9 +++------ src/common/zstream.cpp | 7 ++----- src/dfb/bitmap.cpp | 3 +-- src/generic/dirctrlg.cpp | 6 +----- src/generic/dragimgg.cpp | 3 +-- src/generic/grid.cpp | 3 +-- src/generic/helpext.cpp | 3 +-- src/generic/htmllbox.cpp | 3 +-- src/generic/listctrl.cpp | 4 +--- src/generic/mdig.cpp | 6 +----- src/generic/progdlgg.cpp | 3 +-- src/generic/renderg.cpp | 5 +---- src/generic/scrlwing.cpp | 6 +----- src/generic/spinctlg.cpp | 3 +-- src/generic/timer.cpp | 2 +- src/gtk/clipbrd.cpp | 6 +----- src/gtk/dataview.cpp | 6 +----- src/gtk/gnome/gprint.cpp | 3 +-- src/gtk1/clipbrd.cpp | 9 ++------- src/gtk1/evtloop.cpp | 3 +-- src/html/htmlcell.cpp | 3 +-- src/html/htmlpars.cpp | 3 +-- src/html/htmltag.cpp | 3 +-- src/html/htmlwin.cpp | 15 +++++++-------- src/html/winpars.cpp | 12 +++--------- src/mgl/app.cpp | 9 ++------- src/mgl/bitmap.cpp | 3 +-- src/mgl/evtloop.cpp | 3 +-- src/mgl/settings.cpp | 3 +-- src/motif/accel.cpp | 3 +-- src/motif/app.cpp | 3 +-- src/motif/dialog.cpp | 3 +-- src/motif/evtloop.cpp | 3 +-- src/motif/frame.cpp | 9 ++------- src/motif/spinbutt.cpp | 3 +-- src/motif/toolbar.cpp | 3 +-- src/msw/bitmap.cpp | 3 +-- src/msw/cursor.cpp | 3 +-- src/msw/dialup.cpp | 6 +----- src/msw/fdrepdlg.cpp | 3 +-- src/msw/listctrl.cpp | 9 +++------ src/msw/main.cpp | 3 +-- src/msw/mdi.cpp | 3 +-- src/msw/mediactrl.cpp | 12 ++---------- src/msw/mediactrl_qt.cpp | 6 +----- src/msw/printwin.cpp | 3 +-- src/msw/region.cpp | 7 +------ src/msw/settings.cpp | 3 +-- src/msw/sound.cpp | 6 +----- src/msw/statbmp.cpp | 4 +--- src/msw/statusbar.cpp | 15 +++------------ src/msw/thread.cpp | 9 +++------ src/msw/toolbar.cpp | 12 ++---------- src/msw/treectrl.cpp | 12 ++++-------- src/msw/wince/menuce.cpp | 6 +----- src/msw/window.cpp | 3 +-- src/os2/app.cpp | 6 ++---- src/os2/bitmap.cpp | 6 +----- src/os2/dialog.cpp | 6 +----- src/os2/listctrl.cpp | 6 ++---- src/os2/settings.cpp | 3 +-- src/os2/statbmp.cpp | 4 +--- src/os2/toolbar.cpp | 6 +----- src/os2/treectrl.cpp | 6 +----- src/os2/window.cpp | 6 +----- src/osx/carbon/clipbrd.cpp | 12 ++---------- src/osx/carbon/combobox.cpp | 18 ++++-------------- src/osx/carbon/combobxc.cpp | 5 ++--- src/osx/carbon/dataview.cpp | 6 ++---- src/osx/carbon/dcscreen.cpp | 3 +-- src/osx/carbon/dirmac.cpp | 3 +-- src/osx/carbon/mediactrl.cpp | 6 +----- src/osx/carbon/metafile.cpp | 3 +-- src/osx/carbon/region.cpp | 18 +++--------------- src/osx/carbon/taskbar.cpp | 6 +----- src/osx/carbon/thread.cpp | 6 ++---- src/osx/carbon/tooltip.cpp | 12 ++---------- src/osx/core/bitmap.cpp | 6 +----- src/osx/core/dcmemory.cpp | 6 ++---- src/osx/core/hidjoystick.cpp | 3 +-- src/osx/core/printmac.cpp | 3 +-- src/osx/listbox_osx.cpp | 3 +-- src/osx/nonownedwnd_osx.cpp | 3 +-- src/osx/printdlg_osx.cpp | 5 ++--- src/osx/sound_osx.cpp | 6 +----- src/osx/spinctrl_osx.cpp | 6 ++---- src/osx/window_osx.cpp | 6 +----- src/palmos/app.cpp | 3 +-- src/palmos/ownerdrw.cpp | 3 +-- src/propgrid/advprops.cpp | 15 +++------------ src/propgrid/editors.cpp | 3 +-- src/propgrid/manager.cpp | 3 +-- src/propgrid/propgrid.cpp | 5 ++--- src/richtext/richtextbuffer.cpp | 21 +++++---------------- src/richtext/richtexthtml.cpp | 3 +-- src/stc/PlatWX.cpp | 23 +++++------------------ src/univ/dialog.cpp | 6 +----- src/univ/menu.cpp | 9 ++------- src/univ/scrolbar.cpp | 6 +----- src/unix/dialup.cpp | 9 +++------ src/unix/fontutil.cpp | 4 +--- src/unix/fswatcher_inotify.cpp | 3 +-- src/unix/fswatcher_kqueue.cpp | 9 ++------- src/unix/net.cpp | 6 ++---- src/unix/sound.cpp | 3 +-- src/x11/app.cpp | 6 ++---- src/x11/bitmap.cpp | 3 +-- src/x11/clipbrd.cpp | 9 ++------- src/x11/evtloop.cpp | 3 +-- 162 files changed, 259 insertions(+), 709 deletions(-) diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 941ce02b02..6be65d3237 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -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 ) diff --git a/samples/docview/view.cpp b/samples/docview/view.cpp index ff24096c08..a945c34a45 100644 --- a/samples/docview/view.cpp +++ b/samples/docview/view.cpp @@ -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? diff --git a/samples/dragimag/dragimag.cpp b/samples/dragimag/dragimag.cpp index 0bd71e6f1b..cce62bcdfa 100644 --- a/samples/dragimag/dragimag.cpp +++ b/samples/dragimag/dragimag.cpp @@ -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 diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index c3b3f4be52..e40144364d 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -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); } // ---------------------------------------------------------------------------- diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index ab63144a8e..d5c0e4f181 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -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")); diff --git a/samples/fswatcher/fswatcher.cpp b/samples/fswatcher/fswatcher.cpp index 7b30d4212e..907f46ceaf 100644 --- a/samples/fswatcher/fswatcher.cpp +++ b/samples/fswatcher/fswatcher.cpp @@ -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); } } diff --git a/samples/html/printing/printing.cpp b/samples/html/printing/printing.cpp index db862e7b45..c6390fc413 100644 --- a/samples/html/printing/printing.cpp +++ b/samples/html/printing/printing.cpp @@ -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); } diff --git a/samples/ipc/baseclient.cpp b/samples/ipc/baseclient.cpp index acd1507adc..e196bb26e9 100644 --- a/samples/ipc/baseclient.cpp +++ b/samples/ipc/baseclient.cpp @@ -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(); diff --git a/samples/ipc/baseserver.cpp b/samples/ipc/baseserver.cpp index 6549fdfa42..c5be6d7866 100644 --- a/samples/ipc/baseserver.cpp +++ b/samples/ipc/baseserver.cpp @@ -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"); } } diff --git a/samples/ipc/client.cpp b/samples/ipc/client.cpp index 99f160aaef..bda33916b1 100644 --- a/samples/ipc/client.cpp +++ b/samples/ipc/client.cpp @@ -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")); } diff --git a/samples/ipc/server.cpp b/samples/ipc/server.cpp index 4bd26352a2..26b09f6791 100644 --- a/samples/ipc/server.cpp +++ b/samples/ipc/server.cpp @@ -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"); } diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index 83002fb868..8cbb86316f 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -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); } } diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp index 3baae4694f..cf86915413 100644 --- a/samples/regtest/regtest.cpp +++ b/samples/regtest/regtest.cpp @@ -1031,8 +1031,7 @@ void RegTreeCtrl::TreeNode::OnCollapse() { DestroyChildren(); - delete m_pKey; - m_pKey = NULL; + wxDELETE(m_pKey); } void RegTreeCtrl::TreeNode::Refresh() diff --git a/samples/sockets/baseserver.cpp b/samples/sockets/baseserver.cpp index ae30bce692..01f609f36b 100644 --- a/samples/sockets/baseserver.cpp +++ b/samples/sockets/baseserver.cpp @@ -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; diff --git a/samples/sound/sound.cpp b/samples/sound/sound.cpp index ab745c89ac..d41c7a2a80 100644 --- a/samples/sound/sound.cpp +++ b/samples/sound/sound.cpp @@ -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")); } diff --git a/samples/stc/stctest.cpp b/samples/stc/stctest.cpp index 4b5a4658a2..bfd85359de 100644 --- a/samples/stc/stctest.cpp +++ b/samples/stc/stctest.cpp @@ -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); } diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index 7e5558a1b3..106e9622b8 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -725,8 +725,7 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event)) { if ( m_tbar ) { - delete m_tbar; - m_tbar = NULL; + wxDELETE(m_tbar); } else { diff --git a/samples/widgets/gauge.cpp b/samples/widgets/gauge.cpp index 6daef590da..4ac549366d 100644 --- a/samples/widgets/gauge.cpp +++ b/samples/widgets/gauge.cpp @@ -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) { diff --git a/samples/widgets/notebook.cpp b/samples/widgets/notebook.cpp index ded5de3900..55e30d6cf4 100644 --- a/samples/widgets/notebook.cpp +++ b/samples/widgets/notebook.cpp @@ -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 diff --git a/samples/widgets/statbmp.cpp b/samples/widgets/statbmp.cpp index 5305c65048..69c67bfe89 100644 --- a/samples/widgets/statbmp.cpp +++ b/samples/widgets/statbmp.cpp @@ -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() ) diff --git a/src/cocoa/fontutil.cpp b/src/cocoa/fontutil.cpp index b42c8ebb3f..37ab272a56 100644 --- a/src/cocoa/fontutil.cpp +++ b/src/cocoa/fontutil.cpp @@ -249,9 +249,7 @@ bool wxFontModule::OnInit() void wxFontModule::OnExit() { - delete g_fontHash; - - g_fontHash = NULL; + wxDELETE(g_fontHash); } #endif diff --git a/src/common/any.cpp b/src/common/any.cpp index 5136577dc5..0fa1368257 100644 --- a/src/common/any.cpp +++ b/src/common/any.cpp @@ -223,8 +223,7 @@ public: } virtual void OnExit() { - delete g_wxAnyValueTypeGlobals; - g_wxAnyValueTypeGlobals = NULL; + wxDELETE(g_wxAnyValueTypeGlobals); } private: }; diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 36a65ef6e9..473b190484 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -147,8 +147,7 @@ wxAppConsoleBase::wxAppConsoleBase() // In unicode mode the SetTraceMasks call can cause an apptraits to be // created, but since we are still in the constructor the wrong kind will // be created for GUI apps. Destroy it so it can be created again later. - delete m_traits; - m_traits = NULL; + wxDELETE(m_traits); #endif #endif } @@ -214,11 +213,7 @@ wxEventLoopBase *wxAppConsoleBase::CreateMainLoop() void wxAppConsoleBase::CleanUp() { - if ( m_mainLoop ) - { - delete m_mainLoop; - m_mainLoop = NULL; - } + wxDELETE(m_mainLoop); } // ---------------------------------------------------------------------------- diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index ea48ba716c..844aec1f42 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -128,8 +128,7 @@ void wxAppBase::CleanUp() wxDeleteStockLists(); - delete wxTheColourDatabase; - wxTheColourDatabase = NULL; + wxDELETE(wxTheColourDatabase); wxAppConsole::CleanUp(); } diff --git a/src/common/artprov.cpp b/src/common/artprov.cpp index 3a4f56b04c..e8a50e9bea 100644 --- a/src/common/artprov.cpp +++ b/src/common/artprov.cpp @@ -204,11 +204,8 @@ wxArtProvider::~wxArtProvider() while ( !sm_providers->empty() ) delete *sm_providers->begin(); - delete sm_providers; - sm_providers = NULL; - - delete sm_cache; - sm_cache = NULL; + wxDELETE(sm_providers); + wxDELETE(sm_cache); } } diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index d8cc2b03a8..26a9a6785a 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -223,11 +223,7 @@ wxPrintData::wxPrintData(const wxPrintData& printData) void wxPrintData::SetPrivData( char *privData, int len ) { - if (m_privData) - { - delete [] m_privData; - m_privData = NULL; - } + wxDELETEA(m_privData); m_privDataLen = len; if (m_privDataLen > 0) { @@ -287,11 +283,7 @@ wxPrintData& wxPrintData::operator=(const wxPrintData& data) m_nativeData = data.GetNativeData(); m_nativeData->m_ref++; - if (m_privData) - { - delete [] m_privData; - m_privData = NULL; - } + wxDELETEA(m_privData); m_privDataLen = data.GetPrivDataLen(); if (m_privDataLen > 0) { diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index b32ef217ed..0b5b37d372 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -2034,21 +2034,18 @@ void wxComboCtrlBase::DestroyPopup() if ( m_popup ) m_popup->RemoveEventHandler(m_popupEvtHandler); - delete m_popupEvtHandler; + wxDELETE(m_popupEvtHandler); - delete m_popupInterface; + wxDELETE(m_popupInterface); if ( m_winPopup ) { m_winPopup->RemoveEventHandler(m_popupWinEvtHandler); - delete m_popupWinEvtHandler; - m_popupWinEvtHandler = NULL; + wxDELETE(m_popupWinEvtHandler); m_winPopup->Destroy(); + m_winPopup = NULL; } - m_popupEvtHandler = NULL; - m_popupInterface = NULL; - m_winPopup = NULL; m_popup = NULL; } diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 0ba3bc7d33..1a6b15c16b 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -680,8 +680,7 @@ bool wxStandardDialogLayoutAdapter::DoLayoutAdaptation(wxDialog* dialog) stdButtonSizer->Realize(); else { - delete buttonSizer; - buttonSizer = NULL; + wxDELETE(buttonSizer); } } diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 71c1b15b1f..6544987b1b 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1953,8 +1953,7 @@ bool wxDocChildFrameAnyBase::CloseView(wxCloseEvent& event) // deleted directly not by us as indicated by its doc child frame // pointer still being set m_childView->SetDocChildFrame(NULL); - delete m_childView; - m_childView = NULL; + wxDELETE(m_childView); } m_childDocument = NULL; diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index aa4f5e0533..57a5219095 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -98,11 +98,7 @@ public: virtual bool OnInit() { return true; } virtual void OnExit() { - if ( gs_factory ) - { - delete gs_factory; - gs_factory = NULL; - } + wxDELETE(gs_factory); } DECLARE_DYNAMIC_CLASS(wxDisplayModule) diff --git a/src/common/dynload.cpp b/src/common/dynload.cpp index 1b28e9b47c..a76a190733 100644 --- a/src/common/dynload.cpp +++ b/src/common/dynload.cpp @@ -61,8 +61,7 @@ public: virtual void OnExit() { - delete wxPluginLibrary::ms_classes; - wxPluginLibrary::ms_classes = NULL; + wxDELETE(wxPluginLibrary::ms_classes); wxPluginManager::ClearManifest(); } diff --git a/src/common/encconv.cpp b/src/common/encconv.cpp index a4b7143ff3..efede1710e 100644 --- a/src/common/encconv.cpp +++ b/src/common/encconv.cpp @@ -116,7 +116,7 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e const wxUint16 *in_tbl; const wxUint16 *out_tbl = NULL; - if (m_Table) {delete[] m_Table; m_Table = NULL;} + wxDELETEA(m_Table); if (input_enc == output_enc) {m_JustCopy = true; return true;} diff --git a/src/common/event.cpp b/src/common/event.cpp index 98231a9f5a..cbcf705f28 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -887,8 +887,7 @@ void wxEventHashTable::Clear() delete eTTnode; } - delete[] m_eventTypeTable; - m_eventTypeTable = NULL; + wxDELETEA(m_eventTypeTable); m_size = 0; } diff --git a/src/common/fileback.cpp b/src/common/fileback.cpp index 5544ee7b54..704b54e165 100644 --- a/src/common/fileback.cpp +++ b/src/common/fileback.cpp @@ -168,11 +168,9 @@ wxStreamError wxBackingFileImpl::ReadAt(wxFileOffset pos, m_filelen += count; if (count < m_buflen) { - delete m_stream; - m_stream = NULL; + wxDELETE(m_stream); if (count > 0) { - delete[] m_buf; - m_buf = NULL; + wxDELETEA(m_buf); m_buflen = 0; } m_parenterror = wxSTREAM_READ_ERROR; @@ -182,8 +180,7 @@ wxStreamError wxBackingFileImpl::ReadAt(wxFileOffset pos, m_buflen = 0; if (!m_stream) { - delete[] m_buf; - m_buf = NULL; + wxDELETEA(m_buf); } } @@ -197,8 +194,7 @@ wxStreamError wxBackingFileImpl::ReadAt(wxFileOffset pos, m_parenterror = m_stream->GetLastError(); if (m_parenterror == wxSTREAM_NO_ERROR) m_parenterror = wxSTREAM_EOF; - delete m_stream; - m_stream = NULL; + wxDELETE(m_stream); } } diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index 916c0ea76d..e888407f92 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -92,27 +92,15 @@ wxFrame *wxFrameBase::New(wxWindow *parent, void wxFrameBase::DeleteAllBars() { #if wxUSE_MENUS - if ( m_frameMenuBar ) - { - delete m_frameMenuBar; - m_frameMenuBar = NULL; - } + wxDELETE(m_frameMenuBar); #endif // wxUSE_MENUS #if wxUSE_STATUSBAR - if ( m_frameStatusBar ) - { - delete m_frameStatusBar; - m_frameStatusBar = NULL; - } + wxDELETE(m_frameStatusBar); #endif // wxUSE_STATUSBAR #if wxUSE_TOOLBAR - if ( m_frameToolBar ) - { - delete m_frameToolBar; - m_frameToolBar = NULL; - } + wxDELETE(m_frameToolBar); #endif // wxUSE_TOOLBAR } diff --git a/src/common/fs_arc.cpp b/src/common/fs_arc.cpp index 9d7ae4fe10..7511c8704c 100644 --- a/src/common/fs_arc.cpp +++ b/src/common/fs_arc.cpp @@ -135,10 +135,8 @@ wxArchiveFSEntry *wxArchiveFSCacheDataImpl::AddToCache(wxArchiveEntry *entry) void wxArchiveFSCacheDataImpl::CloseStreams() { - delete m_archive; - m_archive = NULL; - delete m_stream; - m_stream = NULL; + wxDELETE(m_archive); + wxDELETE(m_stream); } wxArchiveEntry *wxArchiveFSCacheDataImpl::Get(const wxString& name) diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 218fa45784..49cba58de6 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -203,8 +203,7 @@ wxSocketBase *wxFTP::AcceptIfActive(wxSocketBase *sock) { m_lastError = wxPROTO_CONNERR; wxLogError(_("Timeout while waiting for FTP server to connect, try passive mode.")); - delete sock; - sock = NULL; + wxDELETE(sock); } else { diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index f2522192b7..cc9045fbe0 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -526,8 +526,7 @@ void wxStockGDI::DeleteAll() { for (unsigned i = 0; i < ITEMCOUNT; i++) { - delete ms_stockObject[i]; - ms_stockObject[i] = NULL; + wxDELETE(ms_stockObject[i]); } } diff --git a/src/common/hash.cpp b/src/common/hash.cpp index 1e36fec843..8c7049b6b4 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp @@ -135,9 +135,7 @@ void wxHashTableBase::Destroy() { Clear(); - delete[] m_table; - - m_table = NULL; + wxDELETEA(m_table); m_size = 0; } diff --git a/src/common/http.cpp b/src/common/http.cpp index c4a6c05dce..9a4833595e 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -251,16 +251,14 @@ bool wxHTTP::Connect(const wxString& host, unsigned short port) wxIPV4address *addr; if (m_addr) { - delete m_addr; - m_addr = NULL; + wxDELETE(m_addr); Close(); } m_addr = addr = new wxIPV4address(); if (!addr->Hostname(host)) { - delete m_addr; - m_addr = NULL; + wxDELETE(m_addr); m_lastError = wxPROTO_NETERR; return false; } diff --git a/src/common/imagiff.cpp b/src/common/imagiff.cpp index 428219853c..16e0348a54 100644 --- a/src/common/imagiff.cpp +++ b/src/common/imagiff.cpp @@ -121,12 +121,9 @@ wxIFFDecoder::wxIFFDecoder(wxInputStream *s) void wxIFFDecoder::Destroy() { - delete m_image; - m_image = 0; - delete [] databuf; - databuf = 0; - delete [] decomp_mem; - decomp_mem = 0; + wxDELETE(m_image); + wxDELETEA(databuf); + wxDELETEA(decomp_mem); } //--------------------------------------------------------------------------- @@ -420,8 +417,7 @@ int wxIFFDecoder::ReadIFF() const byte *cmapptr = dataptr + 8; colors = chunkLen / 3; // calc no of colors - delete m_image->pal; - m_image->pal = 0; + wxDELETE(m_image->pal); m_image->colors = colors; if (colors > 0) { m_image->pal = new byte[3*colors]; @@ -479,8 +475,7 @@ int wxIFFDecoder::ReadIFF() decomprle(bodyptr, decomp_mem, chunkLen, decomp_bufsize); bodyptr = decomp_mem; // -> uncompressed BODY chunkLen = decomp_bufsize; - delete [] databuf; - databuf = 0; + wxDELETEA(databuf); } // the following determines the type of the ILBM file. diff --git a/src/common/init.cpp b/src/common/init.cpp index e220d9860f..561b726ccd 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -204,8 +204,7 @@ static void FreeConvertedArgs() free(gs_initData.argv[i]); } - delete [] gs_initData.argv; - gs_initData.argv = NULL; + wxDELETEA(gs_initData.argv); gs_initData.argc = 0; } } diff --git a/src/common/intl.cpp b/src/common/intl.cpp index cffa1cd034..25152b4cb8 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -200,8 +200,7 @@ wxLanguageInfoArray *wxLocale::ms_languagesDB = NULL; /*static*/ void wxLocale::DestroyLanguagesDB() { - delete ms_languagesDB; - ms_languagesDB = NULL; + wxDELETE(ms_languagesDB); } diff --git a/src/common/mediactrlcmn.cpp b/src/common/mediactrlcmn.cpp index 15a67c9067..a1273c75f5 100644 --- a/src/common/mediactrlcmn.cpp +++ b/src/common/mediactrlcmn.cpp @@ -107,8 +107,7 @@ bool wxMediaCtrl::Create(wxWindow* parent, wxWindowID id, { if (!Load(fileName)) { - delete m_imp; - m_imp = NULL; + wxDELETE(m_imp); return false; } } @@ -172,8 +171,7 @@ bool wxMediaCtrl::Create(wxWindow* parent, wxWindowID id, if (!Load(location)) { - delete m_imp; - m_imp = NULL; + wxDELETE(m_imp); return false; } diff --git a/src/common/mimecmn.cpp b/src/common/mimecmn.cpp index 332404b839..2171a14328 100644 --- a/src/common/mimecmn.cpp +++ b/src/common/mimecmn.cpp @@ -749,8 +749,7 @@ public: if ( gs_mimeTypesManager.m_impl != NULL ) { - delete gs_mimeTypesManager.m_impl; - gs_mimeTypesManager.m_impl = NULL; + wxDELETE(gs_mimeTypesManager.m_impl); gs_mimeTypesManager.m_fallbacks.Clear(); } } diff --git a/src/common/object.cpp b/src/common/object.cpp index c21fdf02f4..05d4dd13b7 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -283,8 +283,7 @@ void wxClassInfo::Unregister() sm_classTable->Delete(m_className); if ( sm_classTable->GetCount() == 0 ) { - delete sm_classTable; - sm_classTable = NULL; + wxDELETE(sm_classTable); } } } diff --git a/src/common/paper.cpp b/src/common/paper.cpp index 49f76ed77e..db2f7e0a5d 100644 --- a/src/common/paper.cpp +++ b/src/common/paper.cpp @@ -374,8 +374,7 @@ bool wxPrintPaperModule::OnInit() void wxPrintPaperModule::OnExit() { - delete wxThePrintPaperDatabase; - wxThePrintPaperDatabase = NULL; + wxDELETE(wxThePrintPaperDatabase); } #endif // wxUSE_PRINTING_ARCHITECTURE diff --git a/src/common/radiocmn.cpp b/src/common/radiocmn.cpp index 766bd52109..aa78ea9638 100644 --- a/src/common/radiocmn.cpp +++ b/src/common/radiocmn.cpp @@ -189,8 +189,7 @@ void wxRadioBoxBase::SetItemToolTip(unsigned int item, const wxString& text) if ( tooltip ) { // delete the tooltip - delete tooltip; - tooltip = NULL; + wxDELETE(tooltip); } else // nothing to do { diff --git a/src/common/regex.cpp b/src/common/regex.cpp index f81154d510..4683b81de3 100644 --- a/src/common/regex.cpp +++ b/src/common/regex.cpp @@ -646,8 +646,7 @@ bool wxRegEx::Compile(const wxString& expr, int flags) if ( !m_impl->Compile(expr, flags) ) { // error message already given in wxRegExImpl::Compile - delete m_impl; - m_impl = NULL; + wxDELETE(m_impl); return false; } diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 228fe79a28..59f9f805f2 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -1789,8 +1789,7 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr, if (m_impl->CreateServer() != wxSOCKET_NOERROR) { - delete m_impl; - m_impl = NULL; + wxDELETE(m_impl); wxLogTrace( wxTRACE_Socket, wxT("*** CreateServer() failed") ); return; @@ -2030,8 +2029,7 @@ wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr, if ( m_impl->CreateUDP() != wxSOCKET_NOERROR ) { - delete m_impl; - m_impl = NULL; + wxDELETE(m_impl); return; } diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 7e7136ae9e..a58245815d 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -3013,10 +3013,9 @@ wxCSConv& wxCSConv::operator=(const wxCSConv& conv) void wxCSConv::Clear() { free(m_name); - delete m_convReal; + wxDELETE(m_convReal); m_name = NULL; - m_convReal = NULL; } void wxCSConv::SetName(const char *charset) diff --git a/src/common/url.cpp b/src/common/url.cpp index 383a5d088b..c0fb31cac2 100644 --- a/src/common/url.cpp +++ b/src/common/url.cpp @@ -365,8 +365,7 @@ void wxURL::SetDefaultProxy(const wxString& url_proxy) if ( ms_proxyDefault ) { ms_proxyDefault->Close(); - delete ms_proxyDefault; - ms_proxyDefault = NULL; + wxDELETE(ms_proxyDefault); } } else @@ -487,8 +486,7 @@ bool wxURLModule::OnInit() void wxURLModule::OnExit() { #if wxUSE_PROTOCOL_HTTP - delete wxURL::ms_proxyDefault; - wxURL::ms_proxyDefault = NULL; + wxDELETE(wxURL::ms_proxyDefault); #endif // wxUSE_PROTOCOL_HTTP } diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index c77972ce10..53791d386f 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -355,8 +355,7 @@ void wxPlatform::AddPlatform(int platform) void wxPlatform::ClearPlatforms() { - delete sm_customPlatforms; - sm_customPlatforms = NULL; + wxDELETE(sm_customPlatforms); } /// Function for testing current platform diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 74cfe913ff..de643e1050 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -364,8 +364,7 @@ wxWindowBase::~wxWindowBase() // This removes any dangling pointers to this window in other windows' // constraintsInvolvedIn lists. UnsetConstraints(m_constraints); - delete m_constraints; - m_constraints = NULL; + wxDELETE(m_constraints); } #endif // wxUSE_CONSTRAINTS @@ -1254,8 +1253,7 @@ wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler) if ( deleteHandler ) { - delete firstHandler; - firstHandler = NULL; + wxDELETE(firstHandler); } return firstHandler; @@ -2076,8 +2074,7 @@ void wxWindowBase::DeleteRelatedConstraints() node = next; } - delete m_constraintsInvolvedIn; - m_constraintsInvolvedIn = NULL; + wxDELETE(m_constraintsInvolvedIn); } } diff --git a/src/common/zstream.cpp b/src/common/zstream.cpp index 8283811fbb..c293548a04 100644 --- a/src/common/zstream.cpp +++ b/src/common/zstream.cpp @@ -335,11 +335,8 @@ bool wxZlibOutputStream::Close() { DoFlush(true); deflateEnd(m_deflate); - delete m_deflate; - - m_deflate = NULL; - delete[] m_z_buffer; - m_z_buffer = NULL; + wxDELETE(m_deflate); + wxDELETEA(m_z_buffer); return wxFilterOutputStream::Close() && IsOk(); } diff --git a/src/dfb/bitmap.cpp b/src/dfb/bitmap.cpp index 239520cb7c..35206ace5f 100644 --- a/src/dfb/bitmap.cpp +++ b/src/dfb/bitmap.cpp @@ -696,8 +696,7 @@ void wxBitmap::SetPalette(const wxPalette& palette) wxCHECK_RET( GetDepth() > 1 && GetDepth() <= 8, wxT("cannot set palette for bitmap of this depth") ); AllocExclusive(); - delete M_BITMAP->m_palette; - M_BITMAP->m_palette = NULL; + wxDELETE(M_BITMAP->m_palette); if ( !palette.Ok() ) return; diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index f071699517..46b72cf08a 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -1496,11 +1496,7 @@ public: bool OnInit() { wxTheFileIconsTable = new wxFileIconsTable; return true; } void OnExit() { - if (wxTheFileIconsTable) - { - delete wxTheFileIconsTable; - wxTheFileIconsTable = NULL; - } + wxDELETE(wxTheFileIconsTable); } }; diff --git a/src/generic/dragimgg.cpp b/src/generic/dragimgg.cpp index 31dcc04f7a..e4b50c9f34 100644 --- a/src/generic/dragimgg.cpp +++ b/src/generic/dragimgg.cpp @@ -358,8 +358,7 @@ bool wxGenericDragImage::EndDrag() #else m_windowDC->DestroyClippingRegion(); #endif - delete m_windowDC; - m_windowDC = NULL; + wxDELETE(m_windowDC); } #ifndef wxHAS_NATIVE_OVERLAY diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index e4ff36d0a1..887ba87cf0 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2100,8 +2100,7 @@ wxGrid::SetTable(wxGridTableBase *table, m_table = NULL; } - delete m_selection; - m_selection = NULL; + wxDELETE(m_selection); m_ownTable = false; m_numRows = 0; diff --git a/src/generic/helpext.cpp b/src/generic/helpext.cpp index 4f1f2543c4..efd0df5116 100644 --- a/src/generic/helpext.cpp +++ b/src/generic/helpext.cpp @@ -154,8 +154,7 @@ void wxExtHelpController::DeleteList() node = m_MapList->GetFirst(); } - delete m_MapList; - m_MapList = NULL; + wxDELETE(m_MapList); } } diff --git a/src/generic/htmllbox.cpp b/src/generic/htmllbox.cpp index c684838d5a..8f75e7375f 100644 --- a/src/generic/htmllbox.cpp +++ b/src/generic/htmllbox.cpp @@ -66,8 +66,7 @@ private: void InvalidateItem(size_t n) { m_items[n] = (size_t)-1; - delete m_cells[n]; - m_cells[n] = NULL; + wxDELETE(m_cells[n]); } public: diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index b5b4600220..1efbc040ea 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -4329,9 +4329,7 @@ void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded() { GetSizer()->Detach( m_headerWin ); - delete m_headerWin; - - m_headerWin = NULL; + wxDELETE(m_headerWin); } } diff --git a/src/generic/mdig.cpp b/src/generic/mdig.cpp index 591bae2bc4..0c139b9470 100644 --- a/src/generic/mdig.cpp +++ b/src/generic/mdig.cpp @@ -74,11 +74,7 @@ wxGenericMDIParentFrame::~wxGenericMDIParentFrame() wxDELETE(m_clientWindow); #if wxUSE_MENUS - if (m_pMyMenuBar) - { - delete m_pMyMenuBar; - m_pMyMenuBar = NULL; - } + wxDELETE(m_pMyMenuBar); RemoveWindowMenu(GetMenuBar()); #endif // wxUSE_MENUS diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index 8e8eb329c7..3c962a0f2e 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -635,8 +635,7 @@ void wxProgressDialog::ReenableOtherWindows() { if ( HasFlag(wxPD_APP_MODAL) ) { - delete m_winDisabler; - m_winDisabler = NULL; + wxDELETE(m_winDisabler); } else { diff --git a/src/generic/renderg.cpp b/src/generic/renderg.cpp index 016d2a32c1..45c1787246 100644 --- a/src/generic/renderg.cpp +++ b/src/generic/renderg.cpp @@ -183,10 +183,7 @@ wxRendererNative& wxRendererNative::GetGeneric() void wxRendererGeneric::Cleanup() { - if (sm_rendererGeneric) - delete sm_rendererGeneric; - - sm_rendererGeneric = NULL; + wxDELETE(sm_rendererGeneric); } wxRendererGeneric* wxRendererGeneric::sm_rendererGeneric = NULL; diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 6244d494a0..c5329862e2 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -926,11 +926,7 @@ bool wxScrollHelperBase::SendAutoScrollEvents(wxScrollWinEvent& event) const void wxScrollHelperBase::StopAutoScrolling() { #if wxUSE_TIMER - if ( m_timerAutoScroll ) - { - delete m_timerAutoScroll; - m_timerAutoScroll = NULL; - } + wxDELETE(m_timerAutoScroll); #endif } diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index e11a6e0a46..fb679bc1bb 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -248,8 +248,7 @@ wxSpinCtrlGenericBase::~wxSpinCtrlGenericBase() delete text; } - delete m_spinButton; - m_spinButton = NULL; + wxDELETE(m_spinButton); } // ---------------------------------------------------------------------------- diff --git a/src/generic/timer.cpp b/src/generic/timer.cpp index cd39aaac34..729daa5011 100644 --- a/src/generic/timer.cpp +++ b/src/generic/timer.cpp @@ -273,7 +273,7 @@ DECLARE_DYNAMIC_CLASS(wxTimerModule) public: wxTimerModule() {} bool OnInit() { return true; } - void OnExit() { delete gs_scheduler; gs_scheduler = NULL; } + void OnExit() { wxDELETE(gs_scheduler); } }; IMPLEMENT_DYNAMIC_CLASS(wxTimerModule, wxModule) diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index 56fa9e1eb8..7fe76b4e66 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -485,11 +485,7 @@ GdkAtom wxClipboard::GTKGetClipboardAtom() const void wxClipboard::GTKClearData(Kind kind) { wxDataObject *&data = Data(kind); - if ( data ) - { - delete data; - data = NULL; - } + wxDELETE(data); } bool wxClipboard::SetSelectionOwner(bool set) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index bc3f27ad35..dc98b83b90 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -4349,11 +4349,7 @@ void wxDataViewCtrl::OnInternalIdle() bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model ) { - if ( m_internal ) - { - delete m_internal; - m_internal = NULL; - } + wxDELETE(m_internal); if (!wxDataViewCtrlBase::AssociateModel( model )) return false; diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index 129f5a64c9..32d206a236 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -2028,8 +2028,7 @@ bool wxGnomePrintModule::OnInit() void wxGnomePrintModule::OnExit() { - delete gs_libGnomePrint; - gs_libGnomePrint = NULL; + wxDELETE(gs_libGnomePrint); } IMPLEMENT_DYNAMIC_CLASS(wxGnomePrintModule, wxModule) diff --git a/src/gtk1/clipbrd.cpp b/src/gtk1/clipbrd.cpp index 6ff7ed1192..2c5b0ff885 100644 --- a/src/gtk1/clipbrd.cpp +++ b/src/gtk1/clipbrd.cpp @@ -216,8 +216,7 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) { wxLogTrace(TRACE_CLIPBOARD, wxT("wxClipboard will get cleared" )); - delete wxTheClipboard->m_data; - wxTheClipboard->m_data = NULL; + wxDELETE(wxTheClipboard->m_data); } } @@ -383,11 +382,7 @@ void wxClipboard::Clear() while (m_waiting) gtk_main_iteration(); } - if (m_data) - { - delete m_data; - m_data = NULL; - } + wxDELETE(m_data); #if wxUSE_THREADS /* re-enable GUI threads */ diff --git a/src/gtk1/evtloop.cpp b/src/gtk1/evtloop.cpp index 194e553bed..ce50f0cf07 100644 --- a/src/gtk1/evtloop.cpp +++ b/src/gtk1/evtloop.cpp @@ -79,8 +79,7 @@ int wxGUIEventLoop::Run() OnExit(); int exitcode = m_impl->GetExitCode(); - delete m_impl; - m_impl = NULL; + wxDELETE(m_impl); return exitcode; } diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index 489375df7e..e1f495e0a0 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -237,8 +237,7 @@ bool wxHtmlCell::AdjustPagebreak(int *pagebreak, void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link) { - if (m_Link) delete m_Link; - m_Link = NULL; + wxDELETE(m_Link); if (link.GetHref() != wxEmptyString) m_Link = new wxHtmlLinkInfo(link); } diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 3c312275a7..2076129925 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -250,8 +250,7 @@ void wxHtmlParser::DestroyDOMTree() } m_Tags = m_CurTag = NULL; - delete m_TextPieces; - m_TextPieces = NULL; + wxDELETE(m_TextPieces); } void wxHtmlParser::DoParsing() diff --git a/src/html/htmltag.cpp b/src/html/htmltag.cpp index 3f88bf3edc..6646ac1ed7 100644 --- a/src/html/htmltag.cpp +++ b/src/html/htmltag.cpp @@ -205,8 +205,7 @@ wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source) for ( wxHtmlTagsCacheData::iterator i = Cache().begin(); i != Cache().end(); ++i ) { - delete[] i->Name; - i->Name = NULL; + wxDELETEA(i->Name); } } diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index f61561184f..a19f7c4206 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -469,14 +469,13 @@ bool wxHtmlWindow::DoSetPage(const wxString& source) SetBackgroundImage(wxNullBitmap); m_Parser->SetDC(dc); - if (m_Cell) - { - delete m_Cell; - // notice that it's important to set m_Cell to NULL here before calling - // Parse() below, even if it will be overwritten by its return value: - // without this we may crash if it's used from inside Parse() - m_Cell = NULL; - } + + // notice that it's important to set m_Cell to NULL here before calling + // Parse() below, even if it will be overwritten by its return value as + // without this we may crash if it's used from inside Parse(), so use + // wxDELETE() and not just delete here + wxDELETE(m_Cell); + m_Cell = (wxHtmlContainerCell*) m_Parser->Parse(newsrc); delete dc; m_Cell->SetIndent(m_Borders, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS); diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 9deb4545c0..916c43a989 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -606,8 +606,7 @@ wxFont* wxHtmlWinParser::CreateCurrentFont() #endif )) { - delete *fontptr; - *fontptr = NULL; + wxDELETE(*fontptr); } if (*fontptr == NULL) @@ -669,11 +668,7 @@ void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc) m_nbsp = 0; m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT; - if (m_EncConv) - { - delete m_EncConv; - m_EncConv = NULL; - } + wxDELETE(m_EncConv); if (enc == wxFONTENCODING_DEFAULT) return; @@ -738,8 +733,7 @@ void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc) wxLogError(_("Failed to display HTML document in %s encoding"), wxFontMapper::GetEncodingName(enc).c_str()); m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT; - delete m_EncConv; - m_EncConv = NULL; + wxDELETE(m_EncConv); } } #endif diff --git a/src/mgl/app.cpp b/src/mgl/app.cpp index 113516fe71..a62f4ac677 100644 --- a/src/mgl/app.cpp +++ b/src/mgl/app.cpp @@ -120,8 +120,7 @@ static bool wxCreateMGL_WM(const wxVideoMode& displayMode) g_displayDC = new MGLDisplayDC(mode, 1, refresh); if ( !g_displayDC->isValid() ) { - delete g_displayDC; - g_displayDC = NULL; + wxDELETE(g_displayDC); return false; } @@ -139,11 +138,7 @@ static void wxDestroyMGL_WM() MGL_wmDestroy(g_winMng); g_winMng = NULL; } - if ( g_displayDC ) - { - delete g_displayDC; - g_displayDC = NULL; - } + wxDELETE(g_displayDC); } //----------------------------------------------------------------------------- diff --git a/src/mgl/bitmap.cpp b/src/mgl/bitmap.cpp index 3c717d4fe9..5cf71c1672 100644 --- a/src/mgl/bitmap.cpp +++ b/src/mgl/bitmap.cpp @@ -498,8 +498,7 @@ void wxBitmap::SetPalette(const wxPalette& palette) wxCHECK_RET( GetDepth() > 1 && GetDepth() <= 8, wxT("cannot set palette for bitmap of this depth") ); AllocExclusive(); - delete M_BMPDATA->m_palette; - M_BMPDATA->m_palette = NULL; + wxDELETE(M_BMPDATA->m_palette); if ( !palette.Ok() ) return; diff --git a/src/mgl/evtloop.cpp b/src/mgl/evtloop.cpp index 861fc56014..19e5ac7e67 100644 --- a/src/mgl/evtloop.cpp +++ b/src/mgl/evtloop.cpp @@ -143,8 +143,7 @@ int wxGUIEventLoop::Run() OnExit(); int exitcode = m_impl->GetExitCode(); - delete m_impl; - m_impl = NULL; + wxDELETE(m_impl); return exitcode; } diff --git a/src/mgl/settings.cpp b/src/mgl/settings.cpp index 3f3b871660..107eb14b12 100644 --- a/src/mgl/settings.cpp +++ b/src/mgl/settings.cpp @@ -34,8 +34,7 @@ public: virtual bool OnInit() { return true; } virtual void OnExit() { - delete gs_fontDefault; - gs_fontDefault = NULL; + wxDELETE(gs_fontDefault); } private: diff --git a/src/motif/accel.cpp b/src/motif/accel.cpp index ba59df93dd..d66f03b8af 100644 --- a/src/motif/accel.cpp +++ b/src/motif/accel.cpp @@ -45,8 +45,7 @@ wxAcceleratorRefData::wxAcceleratorRefData() wxAcceleratorRefData::~wxAcceleratorRefData() { - delete[] m_entries; - m_entries = NULL; + wxDELETEA(m_entries); m_count = 0; } diff --git a/src/motif/app.cpp b/src/motif/app.cpp index e9fbf1b7d2..4216c8796e 100644 --- a/src/motif/app.cpp +++ b/src/motif/app.cpp @@ -269,8 +269,7 @@ void wxApp::CleanUp() { wxAppBase::CleanUp(); - delete wxWidgetHashTable; - wxWidgetHashTable = NULL; + wxDELETE(wxWidgetHashTable); delete m_mainLoop; diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index 347e11354c..618c22de04 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -307,8 +307,7 @@ int wxDialog::ShowModal() // Now process all events in case they get sent to a destroyed dialog wxFlushEvents( display ); - delete m_eventLoop; - m_eventLoop = NULL; + wxDELETE(m_eventLoop); // TODO: is it safe to call this, if the dialog may have been deleted // by now? Probably only if we're using delayed deletion of dialogs. diff --git a/src/motif/evtloop.cpp b/src/motif/evtloop.cpp index 7fd2475e66..50290c653a 100644 --- a/src/motif/evtloop.cpp +++ b/src/motif/evtloop.cpp @@ -121,8 +121,7 @@ int wxGUIEventLoop::Run() OnExit(); int exitcode = m_impl->GetExitCode(); - delete m_impl; - m_impl = NULL; + wxDELETE(m_impl); return exitcode; } diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index c32ec0a0f4..ea5e996758 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -267,15 +267,10 @@ wxFrame::~wxFrame() if (m_frameMenuBar) { m_frameMenuBar->DestroyMenuBar(); - delete m_frameMenuBar; - m_frameMenuBar = NULL; + wxDELETE(m_frameMenuBar); } - if (m_frameStatusBar) - { - delete m_frameStatusBar; - m_frameStatusBar = NULL; - } + wxDELETE(m_frameStatusBar); PreDestroy(); diff --git a/src/motif/spinbutt.cpp b/src/motif/spinbutt.cpp index fe8e6257b9..6286212ced 100644 --- a/src/motif/spinbutt.cpp +++ b/src/motif/spinbutt.cpp @@ -180,8 +180,7 @@ void wxArrowButton::StopTimerCallback( Widget w, XtPointer clientData, return; wxArrowButton* btn = (wxArrowButton*)clientData; - delete btn->m_timer; - btn->m_timer = 0; + wxDELETE(btn->m_timer); } bool wxArrowButton::Create( wxSpinButton* parent, diff --git a/src/motif/toolbar.cpp b/src/motif/toolbar.cpp index 6cc0576b55..77d27351ec 100644 --- a/src/motif/toolbar.cpp +++ b/src/motif/toolbar.cpp @@ -244,8 +244,7 @@ bool wxToolBar::Create(wxWindow *parent, wxToolBar::~wxToolBar() { - delete wxTheToolBarTimer; - wxTheToolBarTimer = NULL; + wxDELETE(wxTheToolBarTimer); } bool wxToolBar::Realize() diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 850baa8602..e903a33e8b 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -238,8 +238,7 @@ void wxBitmapRefData::Free() } } - delete m_bitmapMask; - m_bitmapMask = NULL; + wxDELETE(m_bitmapMask); } // ---------------------------------------------------------------------------- diff --git a/src/msw/cursor.cpp b/src/msw/cursor.cpp index dec1344042..a839795758 100644 --- a/src/msw/cursor.cpp +++ b/src/msw/cursor.cpp @@ -105,8 +105,7 @@ public: virtual void OnExit() { - delete gs_globalCursor; - gs_globalCursor = NULL; + wxDELETE(gs_globalCursor); } }; diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp index b006bdbf37..7b536c9e9e 100644 --- a/src/msw/dialup.cpp +++ b/src/msw/dialup.cpp @@ -597,11 +597,7 @@ void wxDialUpManagerMSW::CleanUpThreadData() m_hThread = 0; } - if ( m_data ) - { - delete m_data; - m_data = NULL; - } + wxDELETE(m_data); } // ---------------------------------------------------------------------------- diff --git a/src/msw/fdrepdlg.cpp b/src/msw/fdrepdlg.cpp index 78b7f27dc2..ac23bf1d95 100644 --- a/src/msw/fdrepdlg.cpp +++ b/src/msw/fdrepdlg.cpp @@ -443,8 +443,7 @@ bool wxFindReplaceDialog::Show(bool show) wxLogError(_("Failed to create the standard find/replace dialog (error code %d)"), ::CommDlgExtendedError()); - delete m_impl; - m_impl = NULL; + wxDELETE(m_impl); return false; } diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 5e0e786436..484443466f 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -497,8 +497,7 @@ void wxListCtrl::DeleteEditControl() { m_textCtrl->UnsubclassWin(); m_textCtrl->SetHWND(0); - delete m_textCtrl; - m_textCtrl = NULL; + wxDELETE(m_textCtrl); } } @@ -1539,8 +1538,7 @@ wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass) if ( !hWnd ) { // failed to start editing - delete m_textCtrl; - m_textCtrl = NULL; + wxDELETE(m_textCtrl); return NULL; } @@ -2246,8 +2244,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) if ( m_internalData[n] == data ) { m_internalData.erase(m_internalData.begin() + n); - delete data; - data = NULL; + wxDELETE(data); break; } } diff --git a/src/msw/main.cpp b/src/msw/main.cpp index 552a864550..3e4338ee95 100644 --- a/src/msw/main.cpp +++ b/src/msw/main.cpp @@ -333,8 +333,7 @@ struct wxMSWCommandLineArguments free(argv[i]); } - delete [] argv; - argv = NULL; + wxDELETEA(argv); argc = 0; } diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 6dd3e63db5..44f8c19f17 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -369,8 +369,7 @@ void wxMDIParentFrame::SetWindowMenu(wxMenu* menu) } #if wxUSE_ACCEL - delete m_accelWindowMenu; - m_accelWindowMenu = NULL; + wxDELETE(m_accelWindowMenu); if ( menu && menu->HasAccels() ) m_accelWindowMenu = menu->CreateAccelTable(); diff --git a/src/msw/mediactrl.cpp b/src/msw/mediactrl.cpp index 2609f78e4b..32adbe9836 100644 --- a/src/msw/mediactrl.cpp +++ b/src/msw/mediactrl.cpp @@ -2193,11 +2193,7 @@ wxAMMediaBackend::~wxAMMediaBackend() //--------------------------------------------------------------------------- void wxAMMediaBackend::Clear() { - if (m_pTimer) - { - delete m_pTimer; - m_pTimer = NULL; - } + wxDELETE(m_pTimer); } //--------------------------------------------------------------------------- @@ -3923,11 +3919,7 @@ void wxQTMediaBackend::Cleanup() { m_bPlaying = false; - if (m_timer) - { - delete m_timer; - m_timer = NULL; - } + wxDELETE(m_timer); m_lib.StopMovie(m_movie); diff --git a/src/msw/mediactrl_qt.cpp b/src/msw/mediactrl_qt.cpp index 694386903f..f5c41dccd2 100644 --- a/src/msw/mediactrl_qt.cpp +++ b/src/msw/mediactrl_qt.cpp @@ -1068,11 +1068,7 @@ void wxQTMediaBackend::Cleanup() { m_bPlaying = false; - if (m_timer) - { - delete m_timer; - m_timer = NULL; - } + wxDELETE(m_timer); m_lib.StopMovie(m_movie); diff --git a/src/msw/printwin.cpp b/src/msw/printwin.cpp index 37e9018b5d..5dba0607ba 100644 --- a/src/msw/printwin.cpp +++ b/src/msw/printwin.cpp @@ -243,8 +243,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt if (sm_abortWindow) { sm_abortWindow->Show(false); - delete sm_abortWindow; - sm_abortWindow = NULL; + wxDELETE(sm_abortWindow); } delete dc; diff --git a/src/msw/region.cpp b/src/msw/region.cpp index 73d983df89..fed4cda96b 100644 --- a/src/msw/region.cpp +++ b/src/msw/region.cpp @@ -384,12 +384,7 @@ void wxRegionIterator::Reset(const wxRegion& region) m_current = 0; m_region = region; - if (m_rects) - { - delete[] m_rects; - - m_rects = NULL; - } + wxDELETEA(m_rects); if (m_region.Empty()) m_numRects = 0; diff --git a/src/msw/settings.cpp b/src/msw/settings.cpp index 84a4ee3348..eec4fea1a9 100644 --- a/src/msw/settings.cpp +++ b/src/msw/settings.cpp @@ -91,8 +91,7 @@ bool wxSystemSettingsModule::OnInit() void wxSystemSettingsModule::OnExit() { - delete gs_fontDefault; - gs_fontDefault = NULL; + wxDELETE(gs_fontDefault); } // ---------------------------------------------------------------------------- diff --git a/src/msw/sound.cpp b/src/msw/sound.cpp index 1996676888..b870321469 100644 --- a/src/msw/sound.cpp +++ b/src/msw/sound.cpp @@ -144,11 +144,7 @@ wxSound::~wxSound() void wxSound::Free() { - if ( m_data ) - { - delete m_data; - m_data = NULL; - } + wxDELETE(m_data); } bool wxSound::CheckCreatedOk() diff --git a/src/msw/statbmp.cpp b/src/msw/statbmp.cpp index 4a460f8816..fbaf004ad1 100644 --- a/src/msw/statbmp.cpp +++ b/src/msw/statbmp.cpp @@ -239,9 +239,7 @@ wxBitmap wxStaticBitmap::GetBitmap() const void wxStaticBitmap::Free() { - delete m_image; - - m_image = NULL; + wxDELETE(m_image); } wxSize wxStaticBitmap::DoGetBestSize() const diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index 8aa705c35e..a7031f4f51 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -179,11 +179,7 @@ wxStatusBar::~wxStatusBar() // delete existing tooltips for (size_t i=0; iLeave(); - delete gs_critsectGui; - gs_critsectGui = NULL; + wxDELETE(gs_critsectGui); } - delete gs_critsectWaitingForGui; - gs_critsectWaitingForGui = NULL; + wxDELETE(gs_critsectWaitingForGui); } // ---------------------------------------------------------------------------- diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index e0a51a13c0..44f08bffb8 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -405,11 +405,7 @@ void wxToolBar::Recreate() m_hBitmap = 0; } - if ( m_disabledImgList ) - { - delete m_disabledImgList; - m_disabledImgList = NULL; - } + wxDELETE(m_disabledImgList); Realize(); } @@ -610,11 +606,7 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) void wxToolBar::CreateDisabledImageList() { - if (m_disabledImgList != NULL) - { - delete m_disabledImgList; - m_disabledImgList = NULL; - } + wxDELETE(m_disabledImgList); // as we can't use disabled image list with older versions of comctl32.dll, // don't even bother creating it diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 9e8c7e31d1..58daae2cf1 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -2029,8 +2029,7 @@ void wxTreeCtrl::DeleteTextCtrl() m_textCtrl->UnsubclassWin(); m_textCtrl->SetHWND(0); - delete m_textCtrl; - m_textCtrl = NULL; + wxDELETE(m_textCtrl); m_idEdited.Unset(); } @@ -2051,8 +2050,7 @@ wxTextCtrl *wxTreeCtrl::EditLabel(const wxTreeItemId& item, // returned false if ( !hWnd ) { - delete m_textCtrl; - m_textCtrl = NULL; + wxDELETE(m_textCtrl); return NULL; } @@ -3134,8 +3132,7 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) if ( m_dragImage ) { m_dragImage->EndDrag(); - delete m_dragImage; - m_dragImage = NULL; + wxDELETE(m_dragImage); // generate the drag end event wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG, @@ -3275,8 +3272,7 @@ wxTreeCtrl::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) if ( m_dragImage ) { m_dragImage->EndDrag(); - delete m_dragImage; - m_dragImage = NULL; + wxDELETE(m_dragImage); // if we don't do it, the tree seems to think that 2 items // are selected simultaneously which is quite weird diff --git a/src/msw/wince/menuce.cpp b/src/msw/wince/menuce.cpp index 4b8c400570..4e80c799c4 100644 --- a/src/msw/wince/menuce.cpp +++ b/src/msw/wince/menuce.cpp @@ -54,11 +54,7 @@ wxTopLevelWindowMSW::ButtonMenu::ButtonMenu() wxTopLevelWindowMSW::ButtonMenu::~ButtonMenu() { - if(m_menu) - { - delete m_menu; - m_menu = NULL; - }; + wxDELETE(m_menu); } void wxTopLevelWindowMSW::SetLeftMenu(int id, const wxString& label, wxMenu *subMenu) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index bc0a9ae9dc..9a6b7259a6 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -3987,8 +3987,7 @@ bool wxWindowMSW::HandleDestroy() { m_dropTarget->Revoke(m_hWnd); - delete m_dropTarget; - m_dropTarget = NULL; + wxDELETE(m_dropTarget); } #endif // wxUSE_DRAG_AND_DROP diff --git a/src/os2/app.cpp b/src/os2/app.cpp index e6a8c71e54..8e98b984bd 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -386,8 +386,7 @@ bool wxApp::RegisterWindowClasses( HAB vHab ) // void wxApp::CleanUp() { - delete[] wxBuffer; - wxBuffer = NULL; + wxDELETEA(wxBuffer); // // PM-SPECIFIC CLEANUP @@ -414,8 +413,7 @@ void wxApp::CleanUp() // TODO: ::DeleteObject( wxDisableButtonBrush ); } - delete wxWinHandleHash; - wxWinHandleHash = NULL; + wxDELETE(wxWinHandleHash); // Delete Message queue if (wxTheApp->m_hMq) diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index f8ae3d715d..74c400fccc 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -84,11 +84,7 @@ void wxBitmapRefData::Free() wxLogLastError(wxT("GpiDeleteBitmap(hbitmap)")); } } - if (m_pBitmapMask) - { - delete m_pBitmapMask; - m_pBitmapMask = NULL; - } + wxDELETE(m_pBitmapMask); } // end of wxBitmapRefData::Free // ---------------------------------------------------------------------------- diff --git a/src/os2/dialog.cpp b/src/os2/dialog.cpp index a8f0d6f9d1..776f9db908 100644 --- a/src/os2/dialog.cpp +++ b/src/os2/dialog.cpp @@ -180,11 +180,7 @@ bool wxDialog::Show( bool bShow ) // and we will lose activation m_modalData->ExitLoop(); #if 0 - if (m_pWindowDisabler) - { - delete m_pWindowDisabler; - m_pWindowDisabler = NULL; - } + wxDELETE(m_pWindowDisabler); #endif } diff --git a/src/os2/listctrl.cpp b/src/os2/listctrl.cpp index 062a528006..57e13fb4e0 100644 --- a/src/os2/listctrl.cpp +++ b/src/os2/listctrl.cpp @@ -140,8 +140,7 @@ public: ~CListItemInternalData() { - delete m_pAttr; - m_pAttr = NULL; + wxDELETE(m_pAttr); } wxListItemAttr* m_pAttr; @@ -965,8 +964,7 @@ wxListCtrl::~wxListCtrl () { m_pTextCtrl->SetHWND(0); m_pTextCtrl->UnsubclassWin(); - delete m_pTextCtrl; - m_pTextCtrl = NULL; + wxDELETE(m_pTextCtrl); } if (m_bOwnsImageListNormal) diff --git a/src/os2/settings.cpp b/src/os2/settings.cpp index 89f7710bdc..c3f6e7bc0f 100644 --- a/src/os2/settings.cpp +++ b/src/os2/settings.cpp @@ -70,8 +70,7 @@ void wxSystemSettingsModule::OnExit() { sm_optionNames.Clear(); sm_optionValues.Clear(); - delete gs_fontDefault; - gs_fontDefault = NULL; + wxDELETE(gs_fontDefault); } wxColour wxSystemSettingsNative::GetColour( diff --git a/src/os2/statbmp.cpp b/src/os2/statbmp.cpp index 52ba6af126..c80642962f 100644 --- a/src/os2/statbmp.cpp +++ b/src/os2/statbmp.cpp @@ -141,9 +141,7 @@ bool wxStaticBitmap::ImageIsOk() const void wxStaticBitmap::Free() { - if (m_pImage) - delete m_pImage; - m_pImage = NULL; + wxDELETE(m_pImage); } // end of wxStaticBitmap::Free wxSize wxStaticBitmap::DoGetBestSize() const diff --git a/src/os2/toolbar.cpp b/src/os2/toolbar.cpp index 8ebc9a0f3e..4bfe61fc7e 100644 --- a/src/os2/toolbar.cpp +++ b/src/os2/toolbar.cpp @@ -423,11 +423,7 @@ bool wxToolBar::Create( wxWindow* pParent, wxToolBar::~wxToolBar() { - if (m_pToolTip) - { - delete m_pToolTip; - m_pToolTip = NULL; - } + wxDELETE(m_pToolTip); } // end of wxToolBar::~wxToolBar bool wxToolBar::Realize() diff --git a/src/os2/treectrl.cpp b/src/os2/treectrl.cpp index edd074f652..ab60bc7c09 100644 --- a/src/os2/treectrl.cpp +++ b/src/os2/treectrl.cpp @@ -80,11 +80,7 @@ public: wxTreeItemInternalData() {} ~wxTreeItemInternalData() { - if(m_pAttr) - { - delete m_pAttr; - m_pAttr = NULL; - } + wxDELETE(m_pAttr); } wxTreeItemAttr* m_pAttr; diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 33862da5f0..fdf6d3a87b 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -3038,11 +3038,7 @@ bool wxWindowOS2::HandleDestroy() // Delete our drop target if we've got one // #if wxUSE_DRAG_AND_DROP - if (m_dropTarget != NULL) - { - delete m_dropTarget; - m_dropTarget = NULL; - } + wxDELETE(m_dropTarget); #endif // wxUSE_DRAG_AND_DROP // diff --git a/src/osx/carbon/clipbrd.cpp b/src/osx/carbon/clipbrd.cpp index a534352a9c..fd8e9a6d45 100644 --- a/src/osx/carbon/clipbrd.cpp +++ b/src/osx/carbon/clipbrd.cpp @@ -61,11 +61,7 @@ wxClipboard::~wxClipboard() void wxClipboard::Clear() { - if (m_data != NULL) - { - delete m_data; - m_data = NULL; - } + wxDELETE(m_data); OSStatus err = PasteboardClear( m_pasteboard ); if (err != noErr) @@ -139,11 +135,7 @@ void wxClipboard::Close() // Get rid of cached object. // If this is not done, copying data from // another application will only work once - if (m_data) - { - delete m_data; - m_data = NULL; - } + wxDELETE(m_data); } bool wxClipboard::IsSupported( const wxDataFormat &dataFormat ) diff --git a/src/osx/carbon/combobox.cpp b/src/osx/carbon/combobox.cpp index 34aba5b850..4245f72fbc 100644 --- a/src/osx/carbon/combobox.cpp +++ b/src/osx/carbon/combobox.cpp @@ -230,17 +230,8 @@ wxComboBox::~wxComboBox() // delete the controls now, don't leave them alive even though they would // still be eventually deleted by our parent - but it will be too late, the // user code expects them to be gone now - if (m_text != NULL) - { - delete m_text; - m_text = NULL; - } - - if (m_choice != NULL) - { - delete m_choice; - m_choice = NULL; - } + wxDELETE(m_text); + wxDELETE(m_choice); } // ---------------------------------------------------------------------------- @@ -471,10 +462,9 @@ void wxComboBox::SetEditable(bool editable) { m_text = new wxComboBoxText( this ); } - else if ( ( m_text != NULL ) && !editable ) + else if ( !editable ) { - delete m_text; - m_text = NULL; + wxDELETE(m_text); } int currentX, currentY; diff --git a/src/osx/carbon/combobxc.cpp b/src/osx/carbon/combobxc.cpp index 16ac22ad1d..b568c23c89 100644 --- a/src/osx/carbon/combobxc.cpp +++ b/src/osx/carbon/combobxc.cpp @@ -478,10 +478,9 @@ void wxComboBox::SetEditable(bool editable) { m_text = new wxComboBoxText( this ); } - else if ( ( m_text != NULL ) && !editable ) + else if ( !editable ) { - delete m_text; - m_text = NULL; + wxDELETE(m_text); } int currentX, currentY; diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index d0b36ae7fb..ef441c892d 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -2092,8 +2092,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject dataObject->Add(textDataObject); else { - delete textDataObject; - textDataObject = NULL; + wxDELETE(textDataObject); } } } /* block */ @@ -2124,8 +2123,7 @@ wxDataObjectComposite* wxMacDataViewDataBrowserListViewControl::GetDnDDataObject dataObject->Add(textDataObject); else { - delete textDataObject; - textDataObject = NULL; + wxDELETE(textDataObject); } } else // overwrite data because the 'utxt' flavor has priority over the 'TEXT' flavor diff --git a/src/osx/carbon/dcscreen.cpp b/src/osx/carbon/dcscreen.cpp index 3b9e51541a..6ce0de678a 100644 --- a/src/osx/carbon/dcscreen.cpp +++ b/src/osx/carbon/dcscreen.cpp @@ -56,8 +56,7 @@ wxScreenDCImpl::wxScreenDCImpl( wxDC *owner ) : wxScreenDCImpl::~wxScreenDCImpl() { - delete m_graphicContext; - m_graphicContext = NULL; + wxDELETE(m_graphicContext); #if wxOSX_USE_COCOA_OR_IPHONE #else DisposeWindow((WindowRef) m_overlayWindow ); diff --git a/src/osx/carbon/dirmac.cpp b/src/osx/carbon/dirmac.cpp index 493829f1f6..1932960d97 100644 --- a/src/osx/carbon/dirmac.cpp +++ b/src/osx/carbon/dirmac.cpp @@ -226,8 +226,7 @@ wxString wxDir::GetName() const wxDir::~wxDir() { - delete m_data; - m_data = NULL; + wxDELETE(m_data); } // ---------------------------------------------------------------------------- diff --git a/src/osx/carbon/mediactrl.cpp b/src/osx/carbon/mediactrl.cpp index 1c79b752e0..ba2e5831e5 100644 --- a/src/osx/carbon/mediactrl.cpp +++ b/src/osx/carbon/mediactrl.cpp @@ -875,11 +875,7 @@ wxMediaState wxQTMediaBackend::GetState() void wxQTMediaBackend::Cleanup() { m_bPlaying = false; - if (m_timer) - { - delete m_timer; - m_timer = NULL; - } + wxDELETE(m_timer); // Stop the movie: // Apple samples with CreateMovieControl typically diff --git a/src/osx/carbon/metafile.cpp b/src/osx/carbon/metafile.cpp index 7bf829e8a2..13d0ef7707 100644 --- a/src/osx/carbon/metafile.cpp +++ b/src/osx/carbon/metafile.cpp @@ -318,8 +318,7 @@ void wxMetafileDCImpl::DoGetSize(int *width, int *height) const wxMetaFile *wxMetafileDCImpl::Close() { - delete m_graphicContext; - m_graphicContext = NULL; + wxDELETE(m_graphicContext); m_ok = false; M_METAFILEREFDATA(*m_metaFile)->Close(); diff --git a/src/osx/carbon/region.cpp b/src/osx/carbon/region.cpp index 20f586b946..28630b83d9 100644 --- a/src/osx/carbon/region.cpp +++ b/src/osx/carbon/region.cpp @@ -346,11 +346,7 @@ wxRegionIterator::wxRegionIterator() wxRegionIterator::~wxRegionIterator() { - if (m_rects) - { - delete [] m_rects; - m_rects = NULL; - } + wxDELETEA(m_rects); } wxRegionIterator::wxRegionIterator(const wxRegionIterator& iterator) @@ -375,11 +371,7 @@ wxRegionIterator& wxRegionIterator::operator=(const wxRegionIterator& iterator) */ void wxRegionIterator::SetRects(long numRects, wxRect *rects) { - if (m_rects) - { - delete [] m_rects; - m_rects = NULL; - } + wxDELETEA(m_rects); if (rects && (numRects > 0)) { @@ -483,11 +475,7 @@ void wxRegionIterator::Reset(const wxRegion& region) m_current = 0; m_region = region; - if (m_rects) - { - delete [] m_rects; - m_rects = NULL; - } + wxDELETEA(m_rects); if (m_region.IsEmpty()) { diff --git a/src/osx/carbon/taskbar.cpp b/src/osx/carbon/taskbar.cpp index 737f6b4977..49b11122b2 100644 --- a/src/osx/carbon/taskbar.cpp +++ b/src/osx/carbon/taskbar.cpp @@ -409,11 +409,7 @@ bool wxDockTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& WXUNUSED(too //----------------------------------------------------------------------------- bool wxDockTaskBarIcon::RemoveIcon() { - if (m_pMenu) - { - delete m_pMenu; - m_pMenu = NULL; - } + wxDELETE(m_pMenu); // restore old icon to the dock OSStatus err = RestoreApplicationDockTileImage(); diff --git a/src/osx/carbon/thread.cpp b/src/osx/carbon/thread.cpp index 2cabb70b5f..e21d6136d7 100644 --- a/src/osx/carbon/thread.cpp +++ b/src/osx/carbon/thread.cpp @@ -1229,12 +1229,10 @@ void wxThreadModule::OnExit() } gs_critsectGui->Leave(); - delete gs_critsectGui; - gs_critsectGui = NULL; + wxDELETE(gs_critsectGui); } - delete gs_critsectWaitingForGui; - gs_critsectWaitingForGui = NULL; + wxDELETE(gs_critsectWaitingForGui); } // ---------------------------------------------------------------------------- diff --git a/src/osx/carbon/tooltip.cpp b/src/osx/carbon/tooltip.cpp index 0b7630ac79..0e642ec612 100644 --- a/src/osx/carbon/tooltip.cpp +++ b/src/osx/carbon/tooltip.cpp @@ -199,11 +199,7 @@ void wxMacToolTip::Setup( WindowRef win , const wxString& text , const wxPoint& wxMacToolTip::~wxMacToolTip() { #if wxUSE_TIMER - if ( m_timer ) - { - delete m_timer ; - m_timer = NULL; - } + wxDELETE(m_timer); #endif // wxUSE_TIMER if ( m_backpict ) Clear() ; @@ -251,11 +247,7 @@ void wxMacToolTip::Clear() { m_mark++ ; #if wxUSE_TIMER - if ( m_timer ) - { - delete m_timer ; - m_timer = NULL ; - } + wxDELETE(m_timer); #endif // wxUSE_TIMER if ( !m_shown ) return ; diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index ebb6ff260f..64d0b39e2d 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -782,11 +782,7 @@ void wxBitmapRefData::Free() m_hBitmap = NULL ; } - if (m_bitmapMask) - { - delete m_bitmapMask; - m_bitmapMask = NULL; - } + wxDELETE(m_bitmapMask); } wxBitmapRefData::~wxBitmapRefData() diff --git a/src/osx/core/dcmemory.cpp b/src/osx/core/dcmemory.cpp index 1debcb3c0e..9610395377 100644 --- a/src/osx/core/dcmemory.cpp +++ b/src/osx/core/dcmemory.cpp @@ -58,8 +58,7 @@ wxMemoryDCImpl::~wxMemoryDCImpl() if ( m_selected.Ok() ) { m_selected.EndRawAccess() ; - delete m_graphicContext ; - m_graphicContext = NULL ; + wxDELETE(m_graphicContext); } } @@ -68,8 +67,7 @@ void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) if ( m_selected.Ok() ) { m_selected.EndRawAccess() ; - delete m_graphicContext ; - m_graphicContext = NULL ; + wxDELETE(m_graphicContext); } m_selected = bitmap; diff --git a/src/osx/core/hidjoystick.cpp b/src/osx/core/hidjoystick.cpp index d21e47cc4f..3bd17b1f33 100644 --- a/src/osx/core/hidjoystick.cpp +++ b/src/osx/core/hidjoystick.cpp @@ -157,8 +157,7 @@ wxJoystick::wxJoystick(int joystick) } else { - delete m_hid; - m_hid = NULL; + wxDELETE(m_hid); } } diff --git a/src/osx/core/printmac.cpp b/src/osx/core/printmac.cpp index 85cc8c2368..4cf4f0cad6 100644 --- a/src/osx/core/printmac.cpp +++ b/src/osx/core/printmac.cpp @@ -718,8 +718,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) if (sm_abortWindow) { sm_abortWindow->Show(false); - delete sm_abortWindow; - sm_abortWindow = NULL; + wxDELETE(sm_abortWindow); } wxEndBusyCursor(); diff --git a/src/osx/listbox_osx.cpp b/src/osx/listbox_osx.cpp index 1394c13019..2e33ac3de6 100644 --- a/src/osx/listbox_osx.cpp +++ b/src/osx/listbox_osx.cpp @@ -108,8 +108,7 @@ wxListBox::~wxListBox() m_blockEvents = false; // make sure no native events get sent to a object in destruction - delete m_peer; - m_peer = NULL; + wxDELETE(m_peer); if ( IsSorted() ) delete m_strings.sorted; diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index b3987670d7..638af1d7ac 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -167,8 +167,7 @@ wxNonOwnedWindow::~wxNonOwnedWindow() DestroyChildren(); - delete m_nowpeer; - m_nowpeer = NULL; + wxDELETE(m_nowpeer); // avoid dangling refs if ( s_macDeactivateWindow == this ) diff --git a/src/osx/printdlg_osx.cpp b/src/osx/printdlg_osx.cpp index c0edeccc56..470e2745fe 100644 --- a/src/osx/printdlg_osx.cpp +++ b/src/osx/printdlg_osx.cpp @@ -67,10 +67,9 @@ bool wxMacPrintDialog::Create( wxWindow *p, wxPrintDialogData *data ) wxMacPrintDialog::~wxMacPrintDialog() { - if (m_destroyDC && m_printerDC) + if (m_destroyDC) { - delete m_printerDC; - m_printerDC = NULL; + wxDELETE(m_printerDC); } } diff --git a/src/osx/sound_osx.cpp b/src/osx/sound_osx.cpp index 1155660e46..ba8d3166f6 100644 --- a/src/osx/sound_osx.cpp +++ b/src/osx/sound_osx.cpp @@ -73,11 +73,7 @@ void wxSoundData::MarkForDeletion() void wxSoundData::Stop() { DoStop(); - if ( m_pTimer ) - { - delete m_pTimer; - m_pTimer = NULL; - } + wxDELETE(m_pTimer); } //Time between timer calls diff --git a/src/osx/spinctrl_osx.cpp b/src/osx/spinctrl_osx.cpp index 8e7042d10e..a6b733ae0a 100644 --- a/src/osx/spinctrl_osx.cpp +++ b/src/osx/spinctrl_osx.cpp @@ -281,10 +281,8 @@ wxSpinCtrl::~wxSpinCtrl() // delete the controls now, don't leave them alive even though they would // still be eventually deleted by our parent - but it will be too late, the // user code expects them to be gone now - delete m_text; - m_text = NULL ; - delete m_btn; - m_btn = NULL ; + wxDELETE(m_text); + wxDELETE(m_btn); } // ---------------------------------------------------------------------------- diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index cd8aecdc4d..707e495537 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -257,11 +257,7 @@ wxWindowMac::~wxWindowMac() // delete our drop target if we've got one #if wxUSE_DRAG_AND_DROP - if ( m_dropTarget != NULL ) - { - delete m_dropTarget; - m_dropTarget = NULL; - } + wxDELETE(m_dropTarget); #endif delete m_peer ; diff --git a/src/palmos/app.cpp b/src/palmos/app.cpp index 9c09f2336f..8ff97b1088 100644 --- a/src/palmos/app.cpp +++ b/src/palmos/app.cpp @@ -209,8 +209,7 @@ void wxApp::CleanUp() // unregister the classes now UnregisterWindowClasses(); - delete wxWinHandleHash; - wxWinHandleHash = NULL; + wxDELETE(wxWinHandleHash); } // ---------------------------------------------------------------------------- diff --git a/src/palmos/ownerdrw.cpp b/src/palmos/ownerdrw.cpp index 261649727f..e3e02226c2 100644 --- a/src/palmos/ownerdrw.cpp +++ b/src/palmos/ownerdrw.cpp @@ -45,8 +45,7 @@ public: virtual void OnExit() { - delete ms_systemMenuFont; - ms_systemMenuFont = NULL; + wxDELETE(ms_systemMenuFont); } static wxFont* ms_systemMenuFont; diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index ba05073f6b..10fab33e5e 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -1821,16 +1821,8 @@ void wxImageFileProperty::OnSetValue() wxFileProperty::OnSetValue(); // Delete old image - if ( m_pImage ) - { - delete m_pImage; - m_pImage = NULL; - } - if ( m_pBitmap ) - { - delete m_pBitmap; - m_pBitmap = NULL; - } + wxDELETE(m_pImage); + wxDELETE(m_pBitmap); wxFileName filename = GetFileName(); @@ -1859,8 +1851,7 @@ void wxImageFileProperty::OnCustomPaint( wxDC& dc, { m_pImage->Rescale( rect.width, rect.height ); m_pBitmap = new wxBitmap( *m_pImage ); - delete m_pImage; - m_pImage = NULL; + wxDELETE(m_pImage); } dc.DrawBitmap( *m_pBitmap, rect.x, rect.y, false ); diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index ed0c11a48f..ba91f1b6fd 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1512,8 +1512,7 @@ END_EVENT_TABLE() wxSimpleCheckBox::~wxSimpleCheckBox() { - delete ms_doubleBuffer; - ms_doubleBuffer = NULL; + wxDELETE(ms_doubleBuffer); } wxBitmap* wxSimpleCheckBox::ms_doubleBuffer = NULL; diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 0b148c403e..911646e70b 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -623,8 +623,7 @@ wxPropertyGridManager::~wxPropertyGridManager() END_MOUSE_CAPTURE //m_pPropGrid->ClearSelection(); - delete m_pPropGrid; - m_pPropGrid = NULL; + wxDELETE(m_pPropGrid); size_t i; for ( i=0; iIsOk()) { - delete customEncoding; - customEncoding = NULL; + wxDELETE(customEncoding); } } if (customEncoding) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index fbc9ce00a3..8f4abde6bd 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -86,8 +86,7 @@ Palette::Palette() { Palette::~Palette() { Release(); - delete [] entries; - entries = 0; + wxDELETEA(entries); } void Palette::Release() { @@ -1144,14 +1143,8 @@ ListBoxImpl::ListBoxImpl() } ListBoxImpl::~ListBoxImpl() { - if (imgList) { - delete imgList; - imgList = NULL; - } - if (imgTypeMap) { - delete imgTypeMap; - imgTypeMap = NULL; - } + wxDELETE(imgList); + wxDELETE(imgTypeMap); } @@ -1329,14 +1322,8 @@ void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { } void ListBoxImpl::ClearRegisteredImages() { - if (imgList) { - delete imgList; - imgList = NULL; - } - if (imgTypeMap) { - delete imgTypeMap; - imgTypeMap = NULL; - } + wxDELETE(imgList); + wxDELETE(imgTypeMap); if (wid) GETLB(wid)->SetImageList(NULL, wxIMAGE_LIST_SMALL); } diff --git a/src/univ/dialog.cpp b/src/univ/dialog.cpp index c0f69439b7..fbb8423f7b 100644 --- a/src/univ/dialog.cpp +++ b/src/univ/dialog.cpp @@ -143,11 +143,7 @@ bool wxDialog::Show(bool show) // if we had disabled other app windows, reenable them back now because // if they stay disabled Windows will activate another window (one // which is enabled, anyhow) and we will lose activation - if ( m_windowDisabler ) - { - delete m_windowDisabler; - m_windowDisabler = NULL; - } + wxDELETE(m_windowDisabler); if ( IsModal() ) EndModal(wxID_CANCEL); diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index 571761f561..c60c14702e 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -1096,11 +1096,7 @@ const wxMenuGeometryInfo& wxMenu::GetGeometryInfo() const void wxMenu::InvalidateGeometryInfo() { - if ( m_geometry ) - { - delete m_geometry; - m_geometry = NULL; - } + wxDELETE(m_geometry); } // ---------------------------------------------------------------------------- @@ -2513,8 +2509,7 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) ms_evtLoopPopup = new wxEventLoop; ms_evtLoopPopup->Run(); - delete ms_evtLoopPopup; - ms_evtLoopPopup = NULL; + wxDELETE(ms_evtLoopPopup); // remove the handler PopEventHandler(true /* delete it */); diff --git a/src/univ/scrolbar.cpp b/src/univ/scrolbar.cpp index 14e705eb06..13c3570f79 100644 --- a/src/univ/scrolbar.cpp +++ b/src/univ/scrolbar.cpp @@ -933,11 +933,7 @@ void wxStdScrollBarInputHandler::StopScrolling(wxScrollBar *control) m_btnCapture = -1; - if ( m_timerScroll ) - { - delete m_timerScroll; - m_timerScroll = NULL; - } + wxDELETE(m_timerScroll); // unpress the arrow and highlight the current element Press(control, false); diff --git a/src/unix/dialup.cpp b/src/unix/dialup.cpp index e43489d82d..edf6657b30 100644 --- a/src/unix/dialup.cpp +++ b/src/unix/dialup.cpp @@ -336,8 +336,7 @@ wxDialUpManagerImpl::Dial(const wxString &isp, m_DialPId = (int)wxExecute(cmd, false, m_DialProcess); if(m_DialPId == 0) { - delete m_DialProcess; - m_DialProcess = NULL; + wxDELETE(m_DialProcess); return false; } else @@ -379,8 +378,7 @@ bool wxDialUpManagerImpl::EnableAutoCheckOnlineStatus(size_t nSeconds) bool rc = m_timer->Start(nSeconds*1000); if(! rc) { - delete m_timer; - m_timer = NULL; + wxDELETE(m_timer); } return rc; } @@ -390,8 +388,7 @@ void wxDialUpManagerImpl::DisableAutoCheckOnlineStatus() if(m_timer != NULL) { m_timer->Stop(); - delete m_timer; - m_timer = NULL; + wxDELETE(m_timer); } } diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index aa47c514c4..a9fac62420 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -1465,9 +1465,7 @@ bool wxFontModule::OnInit() void wxFontModule::OnExit() { - delete g_fontHash; - - g_fontHash = NULL; + wxDELETE(g_fontHash); } #endif // GTK 2.0/1.x diff --git a/src/unix/fswatcher_inotify.cpp b/src/unix/fswatcher_inotify.cpp index edb3c52765..6c27e5c0f2 100644 --- a/src/unix/fswatcher_inotify.cpp +++ b/src/unix/fswatcher_inotify.cpp @@ -91,8 +91,7 @@ public: wxCHECK_RET( IsOk(), "Inotify not initialized or invalid inotify descriptor" ); - delete m_source; - m_source = NULL; + wxDELETE(m_source); if ( close(m_ifd) != 0 ) { diff --git a/src/unix/fswatcher_kqueue.cpp b/src/unix/fswatcher_kqueue.cpp index e1046e2ea4..2c7296a4e0 100644 --- a/src/unix/fswatcher_kqueue.cpp +++ b/src/unix/fswatcher_kqueue.cpp @@ -115,8 +115,7 @@ public: wxLogSysError(_("Error closing kqueue instance")); } - delete m_source; - m_source = NULL; + wxDELETE(m_source); } virtual bool DoAdd(wxSharedPtr watch) @@ -419,11 +418,7 @@ wxKqueueFileSystemWatcher::wxKqueueFileSystemWatcher(const wxFileName& path, { if (!Init()) { - if (m_service) - { - delete m_service; - m_service = NULL; - } + wxDELETE(m_service); return; } diff --git a/src/unix/net.cpp b/src/unix/net.cpp index ab4936b946..0516d9ef1b 100644 --- a/src/unix/net.cpp +++ b/src/unix/net.cpp @@ -236,8 +236,7 @@ wxDialUpManagerImpl::EnableAutoCheckOnlineStatus(size_t nSeconds) bool rc = m_timer->Start(nSeconds*1000); if(! rc) { - delete m_timer; - m_timer = NULL; + wxDELETE(m_timer); } return rc; } @@ -247,8 +246,7 @@ wxDialUpManagerImpl::DisableAutoCheckOnlineStatus() { wxASSERT(m_timer != NULL); m_timer->Stop(); - delete m_timer; - m_timer = NULL; + wxDELETE(m_timer); } diff --git a/src/unix/sound.cpp b/src/unix/sound.cpp index 37b8469aad..500e861718 100644 --- a/src/unix/sound.cpp +++ b/src/unix/sound.cpp @@ -570,8 +570,7 @@ bool wxSound::Create(int size, const wxByte* data) Stop(); - delete ms_backend; - ms_backend = NULL; + wxDELETE(ms_backend); #if wxUSE_LIBSDL && wxUSE_PLUGINS delete ms_backendSDL; #endif diff --git a/src/x11/app.cpp b/src/x11/app.cpp index acd1c49aef..775f77de6b 100644 --- a/src/x11/app.cpp +++ b/src/x11/app.cpp @@ -195,10 +195,8 @@ bool wxApp::Initialize(int& argC, wxChar **argV) void wxApp::CleanUp() { - delete wxWidgetHashTable; - wxWidgetHashTable = NULL; - delete wxClientWidgetHashTable; - wxClientWidgetHashTable = NULL; + wxDELETE(wxWidgetHashTable); + wxDELETE(wxClientWidgetHashTable); wxAppBase::CleanUp(); } diff --git a/src/x11/bitmap.cpp b/src/x11/bitmap.cpp index ce4fd780e3..fac57599b1 100644 --- a/src/x11/bitmap.cpp +++ b/src/x11/bitmap.cpp @@ -1072,8 +1072,7 @@ void wxBitmap::SetPalette(const wxPalette& palette) wxT("cannot set palette for bitmap of this depth")); AllocExclusive(); - delete M_BMPDATA->m_palette; - M_BMPDATA->m_palette = NULL; + wxDELETE(M_BMPDATA->m_palette); if (!palette.Ok()) return; diff --git a/src/x11/clipbrd.cpp b/src/x11/clipbrd.cpp index 13af47b6e8..0e5f06f2ac 100644 --- a/src/x11/clipbrd.cpp +++ b/src/x11/clipbrd.cpp @@ -215,8 +215,7 @@ selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) { wxLogTrace(TRACE_CLIPBOARD, wxT("wxClipboard will get cleared" )); - delete wxTheClipboard->m_data; - wxTheClipboard->m_data = NULL; + wxDELETE(wxTheClipboard->m_data); } } @@ -348,11 +347,7 @@ void wxClipboard::Clear() } #endif - if (m_data) - { - delete m_data; - m_data = NULL; - } + wxDELETE(m_data); #if wxUSE_THREADS /* re-enable GUI threads */ diff --git a/src/x11/evtloop.cpp b/src/x11/evtloop.cpp index 6cd9b2b24a..4f921a4a37 100644 --- a/src/x11/evtloop.cpp +++ b/src/x11/evtloop.cpp @@ -162,8 +162,7 @@ int wxGUIEventLoop::Run() OnExit(); int exitcode = m_impl->GetExitCode(); - delete m_impl; - m_impl = NULL; + wxDELETE(m_impl); return exitcode; } -- 2.45.2