DCSIMG
April 2010 - Posts - Technicals and Technicalities

Technicals and Technicalities

Ariel's uneditable Bliki

April 2010 - Posts

Small WPF4 RC bug

Just in case someone encounters this – WPF4 RC version has a small bug (fixed in the RTM) which has the unfortunate consequence of throwing an exception on a WPF thread (with no user code in the way to handle it), and crashing the application.

Below are the three version of the TextBoxView.ClearLineVisual code (which cause the exception), from ver3, ver4RC and ver4RTM…

private void ClearLineVisual(int lineIndex)
{
    if (((this._viewportLineVisuals != null) && (lineIndex >= this._viewportLineVisualsIndex)) && (lineIndex < (this._viewportLineVisualsIndex + this._viewportLineVisuals.Count)))
    {
        this._viewportLineVisuals[lineIndex - this._viewportLineVisualsIndex] = null;
    }
}
private void ClearLineVisual(int lineIndex)
{
    if (((this._viewportLineVisuals != null) && (lineIndex >= this._viewportLineVisualsIndex)) && (lineIndex < (this._viewportLineVisualsIndex + this._viewportLineVisuals.Count)))
    {
        this._viewportLineVisuals[lineIndex - this._viewportLineVisualsIndex].DiscardOnArrange = true;
        this._viewportLineVisuals[lineIndex - this._viewportLineVisualsIndex] = null;
    }
}
private void ClearLineVisual(int lineIndex)
{
    if (((this._viewportLineVisuals != null) && (lineIndex >= this._viewportLineVisualsIndex)) && ((lineIndex < (this._viewportLineVisualsIndex + this._viewportLineVisuals.Count)) && (this._viewportLineVisuals[lineIndex - this._viewportLineVisualsIndex] != null)))
    {
        this._viewportLineVisuals[lineIndex - this._viewportLineVisualsIndex].DiscardOnArrange = true;
        this._viewportLineVisuals[lineIndex - this._viewportLineVisualsIndex] = null;
    }
}