Kaydet (Commit) a8d1349b authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

fdo#35728: fix GridControl crash

* various forms.OGridControlModel tests segfaulted
* root cause is the migration to stl containers in DbGridControl
* the old tools container returned the removed pointer or NULL causing no failure
* a signed int was used as index while the functions returned a unsigned int
* the GRID_COLUMN_NOT_FOUND magic value was out of the signed range
üst ff6d8de3
...@@ -116,7 +116,7 @@ public: ...@@ -116,7 +116,7 @@ public:
virtual void columnChanged() = 0; virtual void columnChanged() = 0;
}; };
#define GRID_COLUMN_NOT_FOUND ((sal_uInt16)-1) #define GRID_COLUMN_NOT_FOUND SAL_MAX_UINT16
//================================================================== //==================================================================
// InitWindowFacet, describing which aspect of a column's Window to (re-)initialize // InitWindowFacet, describing which aspect of a column's Window to (re-)initialize
......
...@@ -1722,13 +1722,13 @@ sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 nWidth ...@@ -1722,13 +1722,13 @@ sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 nWidth
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void DbGridControl::RemoveColumn(sal_uInt16 nId) void DbGridControl::RemoveColumn(sal_uInt16 nId)
{ {
sal_Int16 nIndex = GetModelColumnPos(nId); const sal_uInt16 nIndex = GetModelColumnPos(nId);
DbGridControl_Base::RemoveColumn(nId); if(nIndex != GRID_COLUMN_NOT_FOUND)
{
delete m_aColumns[ nIndex ]; DbGridControl_Base::RemoveColumn(nId);
DbGridColumns::iterator it = m_aColumns.begin(); delete m_aColumns[nIndex];
::std::advance( it, nIndex ); m_aColumns.erase( m_aColumns.begin()+nIndex );
m_aColumns.erase( it ); }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
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