Fix a potential crash in the edit grid.
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Fri, 18 Sep 2009 14:46:47 +0000 (14:46 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Fri, 18 Sep 2009 14:46:47 +0000 (14:46 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@8040 a7884b65-44f6-0310-8a51-81a127f17b15

CHANGELOG
pgadmin/frm/frmEditGrid.cpp

index 06f9c78eaba95d2de2d6be5fdcbe629dec9ed8e0..e9d3e043242fd3ce820b122a9275fc48bf86b465 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,7 @@ Changes
 
 Date       Dev Ver     Change details
 ---------- --- ------  --------------
+2009-09-18 DP  1.10.1  Fix a potential crash in the edit grid.
 2009-09-17 GL  1.12.0  Add a button to open the query tool with the query
                        selected in the frmStatus window.
 2009-09-04 GL  1.12.0  Add an option to automatically rollback a failed
index ec003700ed9601999f8d6754a2c78ea23a916f4f..028cf1cae8274581f76b025bd617d11f5f012380 100644 (file)
@@ -1038,15 +1038,30 @@ void frmEditGrid::OnDelete(wxCommandEvent& event)
         if (sqlGrid->GetTable()->IsColBoolean(sqlGrid->GetGridCursorCol()))
             return;
 
-        wxStyledTextCtrl *text = (wxStyledTextCtrl *)sqlGrid->GetCellEditor(sqlGrid->GetGridCursorRow(), sqlGrid->GetGridCursorCol())->GetControl();
-        if (text->GetCurrentPos() <= text->GetTextLength())
+        if (sqlGrid->GetTable()->IsColText(sqlGrid->GetGridCursorCol()))
         {
-            int len = text->GetSelectedText().Length();
-            if (len)
-                text->SetSelection(text->GetCurrentPos(), text->GetCurrentPos() + len);
-            else
-                text->SetSelection(text->GetCurrentPos(), text->GetCurrentPos() + 1);
-            text->Clear(); 
+            wxStyledTextCtrl *text = (wxStyledTextCtrl *)sqlGrid->GetCellEditor(sqlGrid->GetGridCursorRow(), sqlGrid->GetGridCursorCol())->GetControl();
+            if (text && text->GetCurrentPos() <= text->GetTextLength())
+            {
+                int len = text->GetSelectedText().Length();
+                if (len)
+                    text->SetSelection(text->GetCurrentPos(), text->GetCurrentPos() + len);
+                else
+                    text->SetSelection(text->GetCurrentPos(), text->GetCurrentPos() + 1);
+                text->Clear(); 
+            }
+        }
+        else
+        {
+            wxTextCtrl *text = (wxTextCtrl *)sqlGrid->GetCellEditor(sqlGrid->GetGridCursorRow(), sqlGrid->GetGridCursorCol())->GetControl();
+            if (text && text->GetInsertionPoint() <= text->GetLastPosition())
+            {
+                int len = text->GetStringSelection().Length();
+                if (len)
+                    text->Remove(text->GetInsertionPoint(), text->GetInsertionPoint() + len);
+                else
+                    text->Remove(text->GetInsertionPoint(), text->GetInsertionPoint() + 1);
+            }
         }
         return;
     }