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:
@@ -11297,6 +11297,21 @@ bool wxRichTextAction::Do()
|
|||||||
CalculateRefreshOptimizations(optimizationLineCharPositions, optimizationLineYPositions);
|
CalculateRefreshOptimizations(optimizationLineCharPositions, optimizationLineYPositions);
|
||||||
#endif
|
#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->DeleteRange(GetRange());
|
||||||
container->UpdateRanges();
|
container->UpdateRanges();
|
||||||
// InvalidateHierarchy goes up the hierarchy as well as down, otherwise with a nested object,
|
// InvalidateHierarchy goes up the hierarchy as well as down, otherwise with a nested object,
|
||||||
@@ -11455,6 +11470,21 @@ bool wxRichTextAction::Undo()
|
|||||||
CalculateRefreshOptimizations(optimizationLineCharPositions, optimizationLineYPositions);
|
CalculateRefreshOptimizations(optimizationLineCharPositions, optimizationLineYPositions);
|
||||||
#endif
|
#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->DeleteRange(GetRange());
|
||||||
container->UpdateRanges();
|
container->UpdateRanges();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user