Fixes segmentation fault due to garbage collection of flex nodes

This commit is contained in:
Atul R 2019-06-06 18:40:52 +02:00
parent c674bcd275
commit 37bafaa64d
2 changed files with 7 additions and 2 deletions

View File

@ -5,11 +5,17 @@ import { NodeLayout } from "../../QtWidgets/QLayout";
export class FlexLayout extends NodeLayout {
native = new addon.FlexLayout();
protected flexNode?: FlexNode;
protected childFlexNodes = new Set<FlexNode>();
addWidget(childWidget: NodeWidget, childFlexNode: FlexNode) {
this.children.add(childWidget);
this.childFlexNodes.add(childFlexNode);
this.native.addWidget(childWidget.native, childFlexNode.native);
}
setFlexNode(flexNode: FlexNode) {
this.flexNode = flexNode;
this.native.setFlexNode(flexNode.native);
}
}

View File

@ -3,7 +3,6 @@ import { FlexNode } from "../FlexLayout/FlexNode";
export abstract class YogaWidget extends Component {
getFlexNode(): FlexNode {
const nativeFlexNode = this.native.getFlexNode();
return new FlexNode(nativeFlexNode);
return new FlexNode(this.native.getFlexNode());
}
}