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:
parent
e39c9f5914
commit
09f3defad8
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user