Avoid crash when deleting range that includes the focus object.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75051 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2013-10-20 17:19:32 +00:00
parent e39c9f5914
commit 09f3defad8

View File

@ -11297,6 +11297,21 @@ bool wxRichTextAction::Do()
CalculateRefreshOptimizations(optimizationLineCharPositions, optimizationLineYPositions);
#endif
// Check if the current object focus needs to be changed before deletion of content
if (m_ctrl)
{
wxRichTextObject* c = m_ctrl->GetFocusObject();
while (c)
{
if (c == container)
{
m_ctrl->StoreFocusObject(container);
break;
}
c = c->GetParent();
}
}
container->DeleteRange(GetRange());
container->UpdateRanges();
// InvalidateHierarchy goes up the hierarchy as well as down, otherwise with a nested object,
@ -11455,6 +11470,21 @@ bool wxRichTextAction::Undo()
CalculateRefreshOptimizations(optimizationLineCharPositions, optimizationLineYPositions);
#endif
// Check if the current object focus needs to be changed before deletion of content
if (m_ctrl)
{
wxRichTextObject* c = m_ctrl->GetFocusObject();
while (c)
{
if (c == container)
{
m_ctrl->StoreFocusObject(container);
break;
}
c = c->GetParent();
}
}
container->DeleteRange(GetRange());
container->UpdateRanges();