Browse Source

Fix null checking

pull/2620/head
Jumar Macato 7 years ago
parent
commit
354a21fddb
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 34
      src/Avalonia.Controls/DefinitionBase.cs
  2. 28
      src/Avalonia.Controls/Grid.cs

34
src/Avalonia.Controls/DefinitionBase.cs

@ -110,11 +110,11 @@ namespace Avalonia.Controls
/// </remarks> /// </remarks>
internal void OnUserSizePropertyChanged(AvaloniaPropertyChangedEventArgs e) internal void OnUserSizePropertyChanged(AvaloniaPropertyChangedEventArgs e)
{ {
if (InParentLogicalTree) if (Parent != null)
{ {
if (_sharedState != null) if (_sharedState != null)
{ {
_sharedState.Invalidate(); _sharedState?.Invalidate();
} }
else else
{ {
@ -129,21 +129,7 @@ namespace Avalonia.Controls
} }
} }
} }
/// <remarks>
/// This method needs to be internal to be accessable from derived classes.
/// </remarks>
internal static void OnUserMinSizePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
{
DefinitionBase definition = (DefinitionBase)d;
if (definition.InParentLogicalTree)
{
Grid parentGrid = (Grid)definition.Parent;
parentGrid.InvalidateMeasure();
}
}
/// <remarks> /// <remarks>
/// This method reflects Grid.SharedScopeProperty state by setting / clearing /// This method reflects Grid.SharedScopeProperty state by setting / clearing
/// dynamic property PrivateSharedSizeScopeProperty. Value of PrivateSharedSizeScopeProperty /// dynamic property PrivateSharedSizeScopeProperty. Value of PrivateSharedSizeScopeProperty
@ -317,14 +303,6 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
internal abstract double UserMaxSizeValueCache { get; } internal abstract double UserMaxSizeValueCache { get; }
/// <summary>
/// Protected. Returns <c>true</c> if this DefinitionBase instance is in parent's logical tree.
/// </summary>
internal bool InParentLogicalTree
{
get { return (_parentIndex != -1); }
}
internal Grid Parent { get; set; } internal Grid Parent { get; set; }
/// <summary> /// <summary>
@ -349,7 +327,7 @@ namespace Avalonia.Controls
{ {
DefinitionBase definition = (DefinitionBase)d; DefinitionBase definition = (DefinitionBase)d;
if (definition.InParentLogicalTree) if (definition.Parent != null)
{ {
string sharedSizeGroupId = (string)e.NewValue; string sharedSizeGroupId = (string)e.NewValue;
@ -421,7 +399,7 @@ namespace Avalonia.Controls
{ {
DefinitionBase definition = (DefinitionBase)d; DefinitionBase definition = (DefinitionBase)d;
if (definition.InParentLogicalTree) if (definition.Parent != null)
{ {
SharedSizeScope privateSharedSizeScope = (SharedSizeScope)e.NewValue; SharedSizeScope privateSharedSizeScope = (SharedSizeScope)e.NewValue;
@ -787,4 +765,4 @@ namespace Avalonia.Controls
PrivateSharedSizeScopeProperty.Changed.AddClassHandler<DefinitionBase>(OnPrivateSharedSizeScopePropertyChanged); PrivateSharedSizeScopeProperty.Changed.AddClassHandler<DefinitionBase>(OnPrivateSharedSizeScopePropertyChanged);
} }
} }
} }

28
src/Avalonia.Controls/Grid.cs

@ -1726,7 +1726,7 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
/// <param name="definitions">Array of definitions to process.</param> /// <param name="definitions">Array of definitions to process.</param>
/// <param name="finalSize">Final size to lay out to.</param> /// <param name="finalSize">Final size to lay out to.</param>
/// <param name="rows">True if sizing row definitions, false for columns</param> /// <param name="columns">True if sizing row definitions, false for columns</param>
private void SetFinalSize( private void SetFinalSize(
IReadOnlyList<DefinitionBase> definitions, IReadOnlyList<DefinitionBase> definitions,
double finalSize, double finalSize,
@ -2303,29 +2303,7 @@ namespace Avalonia.Controls
} }
} }
} }
/// <summary>
/// Returns <c>true</c> if ColumnDefinitions collection is not empty
/// </summary>
public bool ShouldSerializeColumnDefinitions()
{
ExtendedData extData = ExtData;
return (extData != null
&& extData.ColumnDefinitions != null
&& extData.ColumnDefinitions.Count > 0);
}
/// <summary>
/// Returns <c>true</c> if RowDefinitions collection is not empty
/// </summary>
public bool ShouldSerializeRowDefinitions()
{
ExtendedData extData = ExtData;
return (extData != null
&& extData.RowDefinitions != null
&& extData.RowDefinitions.Count > 0);
}
/// <summary> /// <summary>
/// Synchronized ShowGridLines property with the state of the grid's visual collection /// Synchronized ShowGridLines property with the state of the grid's visual collection
/// by adding / removing GridLinesRenderer visual. /// by adding / removing GridLinesRenderer visual.
@ -3392,4 +3370,4 @@ namespace Avalonia.Controls
private static readonly Pen _evenDashPen; // second pen to draw dash private static readonly Pen _evenDashPen; // second pen to draw dash
} }
} }
} }

Loading…
Cancel
Save