浏览代码

Merge pull request #337 from UnityTech/fix_keep_alive_bug_full

fix keep alive bug (full fix)
/main
GitHub 5 年前
当前提交
244d75b0
共有 2 个文件被更改,包括 17 次插入14 次删除
  1. 7
      Runtime/rendering/sliver_multi_box_adaptor.cs
  2. 24
      Runtime/widgets/sliver.cs

7
Runtime/rendering/sliver_multi_box_adaptor.cs


public bool keepAlive = false;
internal bool _keptAlive = false;
public bool keptAlive {
get { return this._keptAlive; }
}
internal bool _keptAlive = false;
public override string ToString() {
return $"index={this.index}; {(this.keepAlive ? "keeyAlive; " : "")}{base.ToString()}";
}

}
public override void insert(RenderBox child, RenderBox after = null) {
D.assert(!this._keepAliveBucket.ContainsValue(value: child));
base.insert(child, after: after);
D.assert(this.firstChild != null);
D.assert(() => {

24
Runtime/widgets/sliver.cs


this._currentBeforeChild = null;
D.assert(this._currentlyUpdatingChildIndex == null);
try {
int firstIndex = 0;
int lastIndex = 0;
if (!this._childElements.isEmpty()) {
firstIndex = this._childElements.First().Key;
lastIndex = this._childElements.Last().Key;
if (this._didUnderflow) {
lastIndex += 1;
}
}
for (int index = firstIndex; index <= lastIndex; ++index) {
void processElement(int index) {
this._currentBeforeChild = (RenderBox) newChild.renderObject;
var parentData = (SliverMultiBoxAdaptorParentData) newChild.renderObject.parentData;
if (!parentData.keptAlive) {
this._currentBeforeChild = (RenderBox) newChild.renderObject;
}
}
// processElement may modify the Map - need to do a .toList() here.
this._childElements.Keys.ToList().ForEach(action: processElement);
if (this._didUnderflow) {
var lastKey = this._childElements?.Last().Key ?? -1;
processElement(lastKey + 1);
}
}
finally {

正在加载...
取消
保存