]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix deleting columns in wxGridStringTable with custom column labels.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 19 Jul 2011 22:35:48 +0000 (22:35 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 19 Jul 2011 22:35:48 +0000 (22:35 +0000)
We erroneously removed too many elements from m_colLabels array (basically we
always removed all the elements remaining after this column, irrespectively of
the actual number of columns to delete), fix this by removing at most the
specified number of columns -- or possibly less if the array isn't entirely
filled.

See #13329.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68306 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/grid.cpp

index 423cfe8bb87b9998a54459121a160a2a0309a2cc..8326934f7f67b3c8dcc3f872fff504a4dd88026f 100644 (file)
@@ -1534,9 +1534,8 @@ bool wxGridStringTable::DeleteCols( size_t pos, size_t numCols )
         // m_colLabels stores just as many elements as it needs, e.g. if only
         // the label of the first column had been set it would have only one
         // element and not numCols, so account for it
-        int nToRm = m_colLabels.size() - colID;
-        if ( nToRm > 0 )
-            m_colLabels.RemoveAt( colID, nToRm );
+        int numRemaining = m_colLabels.size() - colID;
+        m_colLabels.RemoveAt( colID, wxMin(numCols, numRemaining) );
     }
 
     if ( numCols >= curNumCols )