]> git.saurik.com Git - wxWidgets.git/commitdiff
Added Paul Gamman's patch for 0 as FALSE in bool editor and renderer.
authorMichael Bedward <mbedward@ozemail.com.au>
Tue, 8 Aug 2000 10:43:16 +0000 (10:43 +0000)
committerMichael Bedward <mbedward@ozemail.com.au>
Tue, 8 Aug 2000 10:43:16 +0000 (10:43 +0000)
Fixed bug in grid selection code that caused crashes (e.g. when grid
had just 1 col and mode was row selection).

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

src/generic/grid.cpp
src/generic/gridsel.cpp

index baed28017d00288564d091a211bc7ab000528554..5e8559b6c4e58c838b4c0df58dfadbe3eb664d0c 100644 (file)
@@ -1189,7 +1189,10 @@ void wxGridCellBoolEditor::BeginEdit(int row, int col, wxGrid* grid)
     if (grid->GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL))
         m_startValue = grid->GetTable()->GetValueAsBool(row, col);
     else
-        m_startValue = !!grid->GetTable()->GetValue(row, col);
+    {
+        wxString cellval( grid->GetTable()->GetValue(row, col) );
+        m_startValue = !( !cellval || (cellval == "0") );
+    }
     CBox()->SetValue(m_startValue);
     CBox()->SetFocus();
 }
@@ -1795,7 +1798,10 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
     if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
         value = grid.GetTable()->GetValueAsBool(row, col);
     else
-        value = !!grid.GetTable()->GetValue(row, col);
+    {
+        wxString cellval( grid.GetTable()->GetValue(row, col) );
+        value = !( !cellval || (cellval == "0") );
+    }
 
     if ( value )
     {
index f6e4b2ba719804d4d9b5aa4b16eccb71603b668f..2781694fb5bd6d54549a6d7a7aa7017969e0ab72 100644 (file)
@@ -402,7 +402,11 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
     }
 
     // Handle single cell selection in SelectCell.
-    if ( topRow == bottomRow && leftCol == rightCol )
+    // (MB: added check for selection mode here to prevent
+    //  crashes if, for example, we are select rows and the
+    //  grid only has 1 col)
+    if ( m_selectionMode == wxGrid::wxGridSelectCells &&
+         topRow == bottomRow && leftCol == rightCol )
         SelectCell( topRow, leftCol, ControlDown,  ShiftDown,
                     AltDown, MetaDown, sendEvent );