- attr = m_table->GetAttr(row, col, wxGridCellAttr::Cell );
- if ( !attr )
- {
- attr = new wxGridCellAttr;
+ wxCHECK_MSG( m_table, attr,
+ _T("we may only be called if CanHaveAttributes() returned TRUE and then m_table should be !NULL") );
+
+ attr = m_table->GetAttr(row, col, wxGridCellAttr::Cell);
+ if ( !attr )
+ {
+ attr = new wxGridCellAttr(m_defaultCellAttr);
+
+ // artificially inc the ref count to match DecRef() in caller
+ attr->IncRef();
+ m_table->SetAttr(attr, row, col);
+ }