fixed a memory leak and an initialization problem

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12490 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-11-19 20:31:44 +00:00
parent a95821781b
commit 6f36917bbf

View File

@@ -2088,6 +2088,9 @@ void wxGridCellAttrData::SetAttr(wxGridCellAttr *attr, int row, int col)
} }
else else
{ {
// free the old attribute
m_attrs[(size_t)n].attr->DecRef();
if ( attr ) if ( attr )
{ {
// change the attribute // change the attribute
@@ -3607,6 +3610,8 @@ void wxGrid::Create()
wxDefaultSize ); wxDefaultSize );
SetTargetWindow( m_gridWin ); SetTargetWindow( m_gridWin );
Init();
} }
@@ -3624,7 +3629,9 @@ bool wxGrid::CreateGrid( int numRows, int numCols,
m_table->SetView( this ); m_table->SetView( this );
m_ownTable = TRUE; m_ownTable = TRUE;
m_selection = new wxGridSelection( this, selmode ); m_selection = new wxGridSelection( this, selmode );
Init();
CalcDimensions();
m_created = TRUE; m_created = TRUE;
return m_created; return m_created;
@@ -3632,12 +3639,10 @@ bool wxGrid::CreateGrid( int numRows, int numCols,
void wxGrid::SetSelectionMode(wxGrid::wxGridSelectionModes selmode) void wxGrid::SetSelectionMode(wxGrid::wxGridSelectionModes selmode)
{ {
if ( !m_created ) wxCHECK_RET( m_created,
{ wxT("Called wxGrid::SetSelectionMode() before calling CreateGrid()") );
wxFAIL_MSG( wxT("Called wxGrid::SetSelectionMode() before calling CreateGrid()") );
} m_selection->SetSelectionMode( selmode );
else
m_selection->SetSelectionMode( selmode );
} }
bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership, bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
@@ -3664,7 +3669,9 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
if (takeOwnership) if (takeOwnership)
m_ownTable = TRUE; m_ownTable = TRUE;
m_selection = new wxGridSelection( this, selmode ); m_selection = new wxGridSelection( this, selmode );
Init();
CalcDimensions();
m_created = TRUE; m_created = TRUE;
} }
@@ -3746,8 +3753,6 @@ void wxGrid::Init()
m_extraWidth = m_extraWidth =
m_extraHeight = 50; m_extraHeight = 50;
CalcDimensions();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------