fix: prevent MeasureOverride from returning Infinity to Avalonia layout (#2136) (#2137)

This commit is contained in:
Gadfly
2026-02-24 10:35:28 +08:00
committed by GitHub
parent 2a26295e90
commit 2179a25ab8
3 changed files with 7 additions and 6 deletions

View File

@@ -258,7 +258,7 @@ namespace SourceGit.Views
}
var requiredWidth = allowWrap && requiredHeight > 16.0
? availableSize.Width
? (double.IsInfinity(availableSize.Width) ? x + 2 : availableSize.Width)
: x + 2;
InvalidateVisual();
return new Size(requiredWidth, requiredHeight);

View File

@@ -90,7 +90,7 @@ namespace SourceGit.Views
return new Size(scale * imageSize.Width, scale * imageSize.Height);
}
return availableSize;
return new Size(0, 0);
}
}
@@ -206,7 +206,7 @@ namespace SourceGit.Views
var right = NewImage;
if (left == null)
return right == null ? availableSize : GetDesiredSize(right.Size, availableSize);
return right == null ? new Size(0, 0) : GetDesiredSize(right.Size, availableSize);
if (right == null)
return GetDesiredSize(left.Size, availableSize);
@@ -324,7 +324,7 @@ namespace SourceGit.Views
var right = NewImage;
if (left == null)
return right == null ? availableSize : GetDesiredSize(right.Size, availableSize);
return right == null ? new Size(0, 0) : GetDesiredSize(right.Size, availableSize);
if (right == null)
return GetDesiredSize(left.Size, availableSize);
@@ -439,7 +439,7 @@ namespace SourceGit.Views
var right = NewImage;
if (left == null)
return right == null ? availableSize : GetDesiredSize(right.Size, availableSize);
return right == null ? new Size(0, 0) : GetDesiredSize(right.Size, availableSize);
if (right == null)
return GetDesiredSize(left.Size, availableSize);

View File

@@ -120,7 +120,8 @@ namespace SourceGit.Views
var typeface = new Typeface(FontFamily);
var test = new FormattedText("fgl|", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, FontSize, Brushes.White);
var h = Math.Max(18, test.Height);
return new Size(availableSize.Width, h);
var w = double.IsInfinity(availableSize.Width) ? 0 : availableSize.Width;
return new Size(w, h);
}
[GeneratedRegex(@"^On ([^\s]+)\: ")]