Skip to content

Commit

Permalink
[prefab] Try avoiding infinite loop in find
Browse files Browse the repository at this point in the history
  • Loading branch information
EspeuteClement committed Nov 28, 2024
1 parent e6d002d commit dad522e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hide/comp/SceneEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4247,7 +4247,7 @@ class SceneEditor {
}

if (target == sceneData) {
var renderProps = original.find(hrt.prefab.RenderProps, null, true);
var renderProps = original.find(hrt.prefab.RenderProps, null, true, false);
if (renderProps != null)
queueRebuild(target);
}
Expand Down
4 changes: 3 additions & 1 deletion hrt/prefab/Prefab.hx
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ class Prefab {
Find a the first prefab in the tree with the given class that matches the optionnal `filter`.
Returns null if no matching prefab was found
**/
public function find<T:Prefab>(?cl: Class<T>, ?filter : T -> Bool, followRefs : Bool = false ) : Null<T> {
public function find<T:Prefab>(?cl: Class<T>, ?filter : T -> Bool, followRefs : Bool = false, includeDisabled: Bool = true) : Null<T> {
if (!includeDisabled && !enabled)
return null;
var asCl = cl != null ? Std.downcast(this, cl) : cast this;
if (asCl != null)
if (filter == null || filter(asCl))
Expand Down
8 changes: 5 additions & 3 deletions hrt/prefab/Reference.hx
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ class Reference extends Object3D {
}


override public function find<T:Prefab>(?cl: Class<T>, ?filter : T -> Bool, followRefs : Bool = false ) : Null<T> {
var res = super.find(cl, filter, followRefs);
override public function find<T:Prefab>(?cl: Class<T>, ?filter : T -> Bool, followRefs : Bool = false, includeDisabled: Bool = true) : Null<T> {
if (!includeDisabled && !enabled)
return null;
var res = super.find(cl, filter, followRefs, includeDisabled);
if (res == null && followRefs ) {
var p = resolveRef();
if( p != null )
return p.find(cl, filter, followRefs);
return p.find(cl, filter, followRefs, includeDisabled);
}
return res;
}
Expand Down

0 comments on commit dad522e

Please sign in to comment.