浏览代码

Merge pull request #401 from UnityTech/fix_table_deadloop

(hotfix) Fix table deadloop
/main
GitHub 5 年前
当前提交
bd7c3190
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 11
      Runtime/rendering/table.cs

11
Runtime/rendering/table.cs


float deficit = tableWidth - maxWidthConstraint;
int availableColumns = this.columns;
float minimumDeficit = 0.00000001f;
while (deficit > 0.0f && totalFlex > minimumDeficit) {
//(Xingwei Zhu) this deficit is double and set to be 0.00000001f in flutter.
//since we use float by default, making it larger should make sense in most cases
float minimumDeficit = 0.0001f;
while (deficit > minimumDeficit && totalFlex > minimumDeficit) {
float newWidth = widths[x] - deficit * flexes[x].Value / totalFlex;
//(Xingwei Zhu) in case deficit * flexes[x].Value / totalFlex => 0 if deficit is really small, leading to dead loop,
//we amend it with a default larger value to ensure that this loop will eventually end
float newWidth = widths[x] - Mathf.Max(minimumDeficit, deficit * flexes[x].Value / totalFlex);
D.assert(newWidth.isFinite());
if (newWidth <= minWidths[x]) {
deficit -= widths[x] - minWidths[x];

正在加载...
取消
保存