Unplanned
Last Updated: 31 Oct 2018 08:11 by ADMIN
ADMIN
Todor
Created on: 05 Nov 2015 07:40
Category: RichTextBox
Type: Bug Report
0
RichTextBox: Creating a deep copy of Section without any inlines adds empty string Span which leads to exception
Creating deep copy using CreateDeepCopy method of an empty Section (without paragraphs or with one empty paragraph) adds empty string Span which leads to ArgumentOutOfRangeException. 

Workaround: clear the empty string Spans before measuring:

foreach (Span span in sectionClone.EnumerateChildrenOfType<Span>().ToList())
{
    if (string.IsNullOrEmpty(span.Text))
    {
        ((Paragraph)span.Parent).Inlines.Remove(span);
    }
}




Steps to reproduce:

1. Execute the following code-snippet:

RadDocument document = new RadDocument();
Section section = new Section();
section.Blocks.Add(new Paragraph());
document.Sections.Add(section);

RadDocument documentClone = (RadDocument)document.CreateDeepCopy();
Section sectionClone = (Section)section.CreateDeepCopy();
documentClone.Sections.Clear();
documentClone.Sections.Add(sectionClone);
documentClone.EnsureDocumentMeasuredAndArranged();

2. Set the documentClone to a RadRichTextBox instance to visualize it.

3. Try to click in the document.

Observe: ArgumentOutOfRangeException is thrown.
0 comments