Commit 3b1ddd95 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Removed the SAFE_DELETE macro.

In most case the assignment to null was not necessary since it was easily provable that the (local) variable wouldn't have referenced after that anyway.
parent 3c5c795c
...@@ -168,7 +168,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent, ...@@ -168,7 +168,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
EDA_DRAW_FRAME::~EDA_DRAW_FRAME() EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
{ {
SAFE_DELETE( m_currentScreen ); delete m_currentScreen;
m_currentScreen = NULL;
m_auimgr.UnInit(); m_auimgr.UnInit();
} }
......
...@@ -868,7 +868,7 @@ bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorM ...@@ -868,7 +868,7 @@ bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorM
{ {
aErrorMsg.Printf( wxT( "error <%s> in DRAW command %c" ), aErrorMsg.Printf( wxT( "error <%s> in DRAW command %c" ),
GetChars( aErrorMsg ), line[0] ); GetChars( aErrorMsg ), line[0] );
SAFE_DELETE( newEntry ); delete newEntry;
// Flush till end of draw section // Flush till end of draw section
do do
...@@ -913,7 +913,7 @@ bool LIB_COMPONENT::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg ) ...@@ -913,7 +913,7 @@ bool LIB_COMPONENT::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg )
if( !field->Load( aLineReader, aErrorMsg ) ) if( !field->Load( aLineReader, aErrorMsg ) )
{ {
SAFE_DELETE( field ); delete field;
return false; return false;
} }
...@@ -931,7 +931,7 @@ bool LIB_COMPONENT::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg ) ...@@ -931,7 +931,7 @@ bool LIB_COMPONENT::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg )
if( field->GetId() == VALUE ) if( field->GetId() == VALUE )
m_name = field->GetText(); m_name = field->GetText();
SAFE_DELETE( field ); delete field;
} }
else else
{ {
......
...@@ -247,7 +247,7 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -247,7 +247,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
wxStaticText* text = new wxStaticText( m_matrixPanel, -1, wxT( "W" ), pos ); wxStaticText* text = new wxStaticText( m_matrixPanel, -1, wxT( "W" ), pos );
int text_height = text->GetRect().GetHeight(); int text_height = text->GetRect().GetHeight();
bitmap_size.y = std::max( bitmap_size.y, text_height ); bitmap_size.y = std::max( bitmap_size.y, text_height );
SAFE_DELETE( text ); delete text;
// compute the Y pos interval: // compute the Y pos interval:
pos.y = text_height; pos.y = text_height;
......
...@@ -110,7 +110,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType ) ...@@ -110,7 +110,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
if( textItem->GetText().IsEmpty() ) if( textItem->GetText().IsEmpty() )
{ {
SAFE_DELETE( textItem ); delete textItem;
return NULL; return NULL;
} }
......
...@@ -293,7 +293,8 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew ) ...@@ -293,7 +293,8 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
// Clear the screen before open a new file // Clear the screen before open a new file
if( g_RootSheet ) if( g_RootSheet )
{ {
SAFE_DELETE( g_RootSheet ); delete g_RootSheet;
g_RootSheet = NULL;
} }
CreateScreens(); CreateScreens();
......
...@@ -143,7 +143,8 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event ) ...@@ -143,7 +143,8 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
// Delete previous library component, if any // Delete previous library component, if any
if( m_component ) if( m_component )
{ {
SAFE_DELETE( m_component ); delete m_component;
m_component = NULL;
m_aliasName.Empty(); m_aliasName.Empty();
} }
...@@ -212,7 +213,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib ...@@ -212,7 +213,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
if( m_component ) if( m_component )
{ {
SAFE_DELETE( m_component ); delete m_component;
m_aliasName.Empty(); m_aliasName.Empty();
} }
...@@ -574,7 +575,8 @@ All changes will be lost. Discard changes?" ) ) ) ...@@ -574,7 +575,8 @@ All changes will be lost. Discard changes?" ) ) )
} }
else else
{ {
SAFE_DELETE( m_component ); delete m_component;
m_component = NULL;
m_aliasName.Empty(); m_aliasName.Empty();
} }
...@@ -660,7 +662,7 @@ lost!\n\nClear the current component from the screen?" ) ) ) ...@@ -660,7 +662,7 @@ lost!\n\nClear the current component from the screen?" ) ) )
if( m_component ) if( m_component )
{ {
SAFE_DELETE( m_component ); delete m_component;
m_aliasName.Empty(); m_aliasName.Empty();
} }
......
...@@ -232,7 +232,7 @@ again." ); ...@@ -232,7 +232,7 @@ again." );
if( !itemLoaded ) if( !itemLoaded )
{ {
SAFE_DELETE( item ); delete item;
} }
else else
{ {
......
...@@ -274,10 +274,14 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle, ...@@ -274,10 +274,14 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle,
SCH_EDIT_FRAME::~SCH_EDIT_FRAME() SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
{ {
SetScreen( NULL ); SetScreen( NULL );
SAFE_DELETE( m_CurrentSheet ); // a SCH_SHEET_PATH, on the heap. delete m_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
SAFE_DELETE( m_undoItem ); delete m_undoItem;
SAFE_DELETE( g_RootSheet ); delete g_RootSheet;
SAFE_DELETE( m_findReplaceData ); delete m_findReplaceData;
m_CurrentSheet = NULL;
m_undoItem = NULL;
g_RootSheet = NULL;
m_findReplaceData = NULL;
CMP_LIBRARY::RemoveAllLibraries(); CMP_LIBRARY::RemoveAllLibraries();
} }
......
...@@ -292,7 +292,7 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) ...@@ -292,7 +292,7 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
if( item->IsNew() ) if( item->IsNew() )
{ {
SAFE_DELETE( item ); delete item;
} }
else if( item->IsMoving() || item->IsResized() ) else if( item->IsMoving() || item->IsResized() )
{ {
......
...@@ -51,11 +51,6 @@ ...@@ -51,11 +51,6 @@
#include <wx/overlay.h> #include <wx/overlay.h>
#endif #endif
// C++ guarantees that operator delete checks its argument for null-ness
#ifndef SAFE_DELETE
#define SAFE_DELETE( p ) delete (p); (p) = NULL;
#endif
// Option for dialog boxes // Option for dialog boxes
#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT | MAYBE_RESIZE_BORDER #define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT | MAYBE_RESIZE_BORDER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment