From 66312b231018b74864f4d87751f8bb1f14e50f74 Mon Sep 17 00:00:00 2001 From: dpage Date: Fri, 18 Sep 2009 14:46:47 +0000 Subject: [PATCH] Fix a potential crash in the edit grid. git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@8040 a7884b65-44f6-0310-8a51-81a127f17b15 --- CHANGELOG | 1 + pgadmin/frm/frmEditGrid.cpp | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 06f9c78ea..e9d3e0432 100644 --- 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 diff --git a/pgadmin/frm/frmEditGrid.cpp b/pgadmin/frm/frmEditGrid.cpp index ec003700e..028cf1cae 100644 --- a/pgadmin/frm/frmEditGrid.cpp +++ b/pgadmin/frm/frmEditGrid.cpp @@ -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; } -- 2.39.5