From c35a95c75d8512811ee200bad406cfe6305c2809 Mon Sep 17 00:00:00 2001 From: Stefan Neis Date: Sun, 15 Jun 2008 17:26:31 +0000 Subject: [PATCH] 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 --- src/generic/grid.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 821fe25221..55e74368fe 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -83,10 +83,12 @@ struct wxGridCellWithAttr wxGridCellWithAttr& operator=(const wxGridCellWithAttr& other) { coords = other.coords; - attr->DecRef(); - attr = other.attr; - attr->IncRef(); - + if (attr != other.attr) + { + attr->DecRef(); + attr = other.attr; + attr->IncRef(); + } return *this; } @@ -2760,13 +2762,20 @@ void wxGridRowOrColAttrData::SetAttr(wxGridCellAttr *attr, int rowOrCol) int i = m_rowsOrCols.Index(rowOrCol); if ( i == wxNOT_FOUND ) { - // add the attribute - m_rowsOrCols.Add(rowOrCol); - m_attrs.Add(attr); + if ( attr ) + { + // add the attribute + m_rowsOrCols.Add(rowOrCol); + m_attrs.Add(attr); + } + // nothing to remove } else { size_t n = (size_t)i; + if ( m_attrs[n] == attr ) + // nothing to do + return; if ( attr ) { // change the attribute