Fixed problems with reassigning the already assigned attribute, see #9567.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@54245 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2008-06-15 17:26:31 +00:00
parent 906ecfa15d
commit c35a95c75d

View File

@@ -83,10 +83,12 @@ struct wxGridCellWithAttr
wxGridCellWithAttr& operator=(const wxGridCellWithAttr& other) wxGridCellWithAttr& operator=(const wxGridCellWithAttr& other)
{ {
coords = other.coords; coords = other.coords;
attr->DecRef(); if (attr != other.attr)
attr = other.attr; {
attr->IncRef(); attr->DecRef();
attr = other.attr;
attr->IncRef();
}
return *this; return *this;
} }
@@ -2760,13 +2762,20 @@ void wxGridRowOrColAttrData::SetAttr(wxGridCellAttr *attr, int rowOrCol)
int i = m_rowsOrCols.Index(rowOrCol); int i = m_rowsOrCols.Index(rowOrCol);
if ( i == wxNOT_FOUND ) if ( i == wxNOT_FOUND )
{ {
// add the attribute if ( attr )
m_rowsOrCols.Add(rowOrCol); {
m_attrs.Add(attr); // add the attribute
m_rowsOrCols.Add(rowOrCol);
m_attrs.Add(attr);
}
// nothing to remove
} }
else else
{ {
size_t n = (size_t)i; size_t n = (size_t)i;
if ( m_attrs[n] == attr )
// nothing to do
return;
if ( attr ) if ( attr )
{ {
// change the attribute // change the attribute