Skip to content

Commit 483ded2

Browse files
[prefab] Change parent access to catch old @:privateAccess use case
These broke due to the fact that parent doesn't have a setter anymore
1 parent a417f63 commit 483ded2

8 files changed

Lines changed: 14 additions & 13 deletions

File tree

hide_js/hide/comp/SceneEditor.hx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,7 +2483,7 @@ class SceneEditor {
24832483
}
24842484

24852485
for (prefab in prefabs) {
2486-
prefab.parent = targetPrefab;
2486+
targetPrefab.addChild(prefab);
24872487
}
24882488

24892489
var ser = ide.toJSON(targetPrefab.serialize());
@@ -4636,7 +4636,6 @@ class SceneEditor {
46364636
if (prefab == null)
46374637
return null;
46384638

4639-
prefab.parent = parent;
46404639
parent.addChildAt(prefab, index);
46414640

46424641
var ref = Std.downcast(prefab, Reference);
@@ -4843,10 +4842,10 @@ class SceneEditor {
48434842
undo.change(Custom(function(undo) {
48444843
if(undo) {
48454844
effectFunc(true);
4846-
group.parent = null;
4845+
group.remove();
48474846
}
48484847
else {
4849-
group.parent = parent;
4848+
parent.addChild(group);
48504849
effectFunc(false);
48514850
}
48524851
if(undo)

hide_js/hide/tools/ThumbnailGenerator.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class ThumbnailGenerator {
277277
// Remove all editor only prefabs
278278
var toRemove = prefab.findAll(hrt.prefab.Prefab, (p) -> p.editorOnly == true, true);
279279
for (r in toRemove) {
280-
r.parent = null;
280+
r.remove();
281281
}
282282

283283
var prefab = prefab.make(ctx);

hide_js/hide/view/FXEditor.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ class FXEditor extends hide.view.FileView {
706706
// We're currently supporting blending with only 2 curves
707707
for (i in 0...2) {
708708
var c = new Curve(null, null);
709-
c.parent = curve;
709+
curve.addChild(c.parent);
710710
c.name = '$i';
711711
if (i == 0) {
712712
for (k in curve.keys) {

hrt/impl/RemoteConsole.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ class RemoteConsoleConnection {
364364
var prefabView : hide.view.Prefab = cast v;
365365
var toEdit = hrt.prefab.Prefab.createFromDynamic(args.data);
366366
prefabView.createData();
367-
toEdit.parent = prefabView.data;
367+
prefabView.data.addChild(toEdit);
368368
prefabView.sceneEditor.delayReady(() -> {
369369
prefabView.sceneEditor.setPrefab(cast prefabView.data);
370370
prefabView.sceneEditor.selectElements([toEdit], NoHistory);

hrt/prefab/Object3D.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class Object3D extends Prefab {
180180
}
181181

182182
public function getAbsPos( followRefs : Bool = false ) {
183-
inline function getParent( p ) {
183+
inline function getParent( p : Prefab ) {
184184
var parent = p.parent;
185185
if( parent == null && followRefs )
186186
parent = p.shared.parentPrefab;

hrt/prefab/Prefab.hx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class Prefab {
104104
/**
105105
The parent of the prefab in the tree view
106106
**/
107-
public var parent(default, null) : Prefab;
107+
public var parent(get, never) : Prefab;
108+
var _parent : Prefab; // Catch invalid usages of parent in old prefabs
108109

109110
/**
110111
Infos shared by all the prefabs in a given prefab hierarchy (but not by references)
@@ -133,7 +134,8 @@ class Prefab {
133134
return getClassTypeName(thisClass);
134135
}
135136

136-
inline function get_children() return _children ?? NULL_CHILDREN;
137+
inline function get_parent() : Prefab return _parent;
138+
inline function get_children() : Array<Prefab> return _children ?? NULL_CHILDREN;
137139

138140
/**
139141
Instanciate this prefab. If `newContextShared` is given or if `this.shared.isInstance` is false,
@@ -844,7 +846,7 @@ class Prefab {
844846
oldParent._children = null;
845847
}
846848
}
847-
child.parent = newParent;
849+
child._parent = newParent;
848850
if (newParent != null) {
849851
if (newParent._children == null)
850852
newParent._children = [];

hrt/prefab/l3d/MeshSpray.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ class MeshSpray extends Spray {
431431
c.editorRemoveInstanceObjects();
432432
c.dispose();
433433
#end
434-
c.parent = null;
434+
c.remove();
435435
binaryChanged = true;
436436
}
437437
if( !binaryChanged )

hrt/prefab/l3d/modellibrary/ModelLibrary.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ class ModelLibrary extends Prefab {
761761
throw "There is no destination path for saving the model library";
762762

763763
var root = new hrt.prefab.Prefab(null, null);
764-
parent = root;
764+
root.addChild(this);
765765
sys.io.File.saveContent(getSystemPath(path), haxe.Json.stringify(@:privateAccess root.serialize(), "\t"));
766766
}
767767

0 commit comments

Comments
 (0)