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:
Vadim Zeitlin
2010-06-20 18:18:23 +00:00
parent 9ac34ac915
commit 5276b0a53c
162 changed files with 259 additions and 709 deletions

View File

@@ -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 )

View File

@@ -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?

View File

@@ -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

View File

@@ -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);
}
// ----------------------------------------------------------------------------

View File

@@ -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"));

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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");
}
}

View File

@@ -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"));
}

View File

@@ -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");
}

View File

@@ -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);
}
}

View File

@@ -1031,8 +1031,7 @@ void RegTreeCtrl::TreeNode::OnCollapse()
{
DestroyChildren();
delete m_pKey;
m_pKey = NULL;
wxDELETE(m_pKey);
}
void RegTreeCtrl::TreeNode::Refresh()

View File

@@ -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;

View File

@@ -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"));
}

View File

@@ -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);
}

View File

@@ -725,8 +725,7 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
{
if ( m_tbar )
{
delete m_tbar;
m_tbar = NULL;
wxDELETE(m_tbar);
}
else
{

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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() )

View File

@@ -249,9 +249,7 @@ bool wxFontModule::OnInit()
void wxFontModule::OnExit()
{
delete g_fontHash;
g_fontHash = NULL;
wxDELETE(g_fontHash);
}
#endif

View File

@@ -223,8 +223,7 @@ public:
}
virtual void OnExit()
{
delete g_wxAnyValueTypeGlobals;
g_wxAnyValueTypeGlobals = NULL;
wxDELETE(g_wxAnyValueTypeGlobals);
}
private:
};

View File

@@ -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);
}
// ----------------------------------------------------------------------------

View File

@@ -128,8 +128,7 @@ void wxAppBase::CleanUp()
wxDeleteStockLists();
delete wxTheColourDatabase;
wxTheColourDatabase = NULL;
wxDELETE(wxTheColourDatabase);
wxAppConsole::CleanUp();
}

View File

@@ -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);
}
}

View File

@@ -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)
{

View File

@@ -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;
}

View File

@@ -680,8 +680,7 @@ bool wxStandardDialogLayoutAdapter::DoLayoutAdaptation(wxDialog* dialog)
stdButtonSizer->Realize();
else
{
delete buttonSizer;
buttonSizer = NULL;
wxDELETE(buttonSizer);
}
}

View File

@@ -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;

View File

@@ -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)

View File

@@ -61,8 +61,7 @@ public:
virtual void OnExit()
{
delete wxPluginLibrary::ms_classes;
wxPluginLibrary::ms_classes = NULL;
wxDELETE(wxPluginLibrary::ms_classes);
wxPluginManager::ClearManifest();
}

View File

@@ -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;}

View File

@@ -887,8 +887,7 @@ void wxEventHashTable::Clear()
delete eTTnode;
}
delete[] m_eventTypeTable;
m_eventTypeTable = NULL;
wxDELETEA(m_eventTypeTable);
m_size = 0;
}

View File

@@ -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);
}
}

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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
{

View File

@@ -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]);
}
}

View File

@@ -135,9 +135,7 @@ void wxHashTableBase::Destroy()
{
Clear();
delete[] m_table;
m_table = NULL;
wxDELETEA(m_table);
m_size = 0;
}

View File

@@ -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;
}

View File

@@ -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.

View File

@@ -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;
}
}

View File

@@ -200,8 +200,7 @@ wxLanguageInfoArray *wxLocale::ms_languagesDB = NULL;
/*static*/ void wxLocale::DestroyLanguagesDB()
{
delete ms_languagesDB;
ms_languagesDB = NULL;
wxDELETE(ms_languagesDB);
}

View File

@@ -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;
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}
}

View File

@@ -374,8 +374,7 @@ bool wxPrintPaperModule::OnInit()
void wxPrintPaperModule::OnExit()
{
delete wxThePrintPaperDatabase;
wxThePrintPaperDatabase = NULL;
wxDELETE(wxThePrintPaperDatabase);
}
#endif // wxUSE_PRINTING_ARCHITECTURE

View File

@@ -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
{

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -1496,11 +1496,7 @@ public:
bool OnInit() { wxTheFileIconsTable = new wxFileIconsTable; return true; }
void OnExit()
{
if (wxTheFileIconsTable)
{
delete wxTheFileIconsTable;
wxTheFileIconsTable = NULL;
}
wxDELETE(wxTheFileIconsTable);
}
};

View File

@@ -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

View File

@@ -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;

View File

@@ -154,8 +154,7 @@ void wxExtHelpController::DeleteList()
node = m_MapList->GetFirst();
}
delete m_MapList;
m_MapList = NULL;
wxDELETE(m_MapList);
}
}

View File

@@ -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:

View File

@@ -4329,9 +4329,7 @@ void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded()
{
GetSizer()->Detach( m_headerWin );
delete m_headerWin;
m_headerWin = NULL;
wxDELETE(m_headerWin);
}
}

View File

@@ -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

View File

@@ -635,8 +635,7 @@ void wxProgressDialog::ReenableOtherWindows()
{
if ( HasFlag(wxPD_APP_MODAL) )
{
delete m_winDisabler;
m_winDisabler = NULL;
wxDELETE(m_winDisabler);
}
else
{

View File

@@ -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;

View File

@@ -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
}

View File

@@ -248,8 +248,7 @@ wxSpinCtrlGenericBase::~wxSpinCtrlGenericBase()
delete text;
}
delete m_spinButton;
m_spinButton = NULL;
wxDELETE(m_spinButton);
}
// ----------------------------------------------------------------------------

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;

View File

@@ -2028,8 +2028,7 @@ bool wxGnomePrintModule::OnInit()
void wxGnomePrintModule::OnExit()
{
delete gs_libGnomePrint;
gs_libGnomePrint = NULL;
wxDELETE(gs_libGnomePrint);
}
IMPLEMENT_DYNAMIC_CLASS(wxGnomePrintModule, wxModule)

View File

@@ -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 */

View File

@@ -79,8 +79,7 @@ int wxGUIEventLoop::Run()
OnExit();
int exitcode = m_impl->GetExitCode();
delete m_impl;
m_impl = NULL;
wxDELETE(m_impl);
return exitcode;
}

View File

@@ -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);
}

View File

@@ -250,8 +250,7 @@ void wxHtmlParser::DestroyDOMTree()
}
m_Tags = m_CurTag = NULL;
delete m_TextPieces;
m_TextPieces = NULL;
wxDELETE(m_TextPieces);
}
void wxHtmlParser::DoParsing()

View File

@@ -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);
}
}

View File

@@ -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;
}
// 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);

View File

@@ -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

View File

@@ -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);
}
//-----------------------------------------------------------------------------

View File

@@ -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;

View File

@@ -143,8 +143,7 @@ int wxGUIEventLoop::Run()
OnExit();
int exitcode = m_impl->GetExitCode();
delete m_impl;
m_impl = NULL;
wxDELETE(m_impl);
return exitcode;
}

View File

@@ -34,8 +34,7 @@ public:
virtual bool OnInit() { return true; }
virtual void OnExit()
{
delete gs_fontDefault;
gs_fontDefault = NULL;
wxDELETE(gs_fontDefault);
}
private:

View File

@@ -45,8 +45,7 @@ wxAcceleratorRefData::wxAcceleratorRefData()
wxAcceleratorRefData::~wxAcceleratorRefData()
{
delete[] m_entries;
m_entries = NULL;
wxDELETEA(m_entries);
m_count = 0;
}

View File

@@ -269,8 +269,7 @@ void wxApp::CleanUp()
{
wxAppBase::CleanUp();
delete wxWidgetHashTable;
wxWidgetHashTable = NULL;
wxDELETE(wxWidgetHashTable);
delete m_mainLoop;

View File

@@ -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.

View File

@@ -121,8 +121,7 @@ int wxGUIEventLoop::Run()
OnExit();
int exitcode = m_impl->GetExitCode();
delete m_impl;
m_impl = NULL;
wxDELETE(m_impl);
return exitcode;
}

View File

@@ -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();

View File

@@ -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,

View File

@@ -244,8 +244,7 @@ bool wxToolBar::Create(wxWindow *parent,
wxToolBar::~wxToolBar()
{
delete wxTheToolBarTimer;
wxTheToolBarTimer = NULL;
wxDELETE(wxTheToolBarTimer);
}
bool wxToolBar::Realize()

View File

@@ -238,8 +238,7 @@ void wxBitmapRefData::Free()
}
}
delete m_bitmapMask;
m_bitmapMask = NULL;
wxDELETE(m_bitmapMask);
}
// ----------------------------------------------------------------------------

View File

@@ -105,8 +105,7 @@ public:
virtual void OnExit()
{
delete gs_globalCursor;
gs_globalCursor = NULL;
wxDELETE(gs_globalCursor);
}
};

View File

@@ -597,11 +597,7 @@ void wxDialUpManagerMSW::CleanUpThreadData()
m_hThread = 0;
}
if ( m_data )
{
delete m_data;
m_data = NULL;
}
wxDELETE(m_data);
}
// ----------------------------------------------------------------------------

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -333,8 +333,7 @@ struct wxMSWCommandLineArguments
free(argv[i]);
}
delete [] argv;
argv = NULL;
wxDELETEA(argv);
argc = 0;
}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

Some files were not shown because too many files have changed in this diff Show More