From 636cb7a3ecdbaf9a5a1dc34875c7bb739ff0f05b Mon Sep 17 00:00:00 2001 From: inert-aesthetic <153579161+inert-aesthetic@users.noreply.github.com> Date: Wed, 26 Feb 2025 02:17:35 +0900 Subject: [PATCH] Add null checks to some setter related macro --- haxe/ui/components/DropDown.hx | 7 ++++--- haxe/ui/macros/Macros.hx | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/haxe/ui/components/DropDown.hx b/haxe/ui/components/DropDown.hx index 34760d9e1..4526416a4 100644 --- a/haxe/ui/components/DropDown.hx +++ b/haxe/ui/components/DropDown.hx @@ -155,9 +155,10 @@ private class DataSourceBehaviour extends DefaultBehaviour { dropDown.text = ""; } } - - var handler:IDropDownHandler = cast(_component._compositeBuilder, DropDownBuilder).handler; - handler.reset(); + if(_component._compositeBuilder!=null){ + var handler:IDropDownHandler = cast(_component._compositeBuilder, DropDownBuilder).handler; + handler.reset(); + } if (_component.text == null && _component.isReady) { dropDown.selectedIndex = 0; } diff --git a/haxe/ui/macros/Macros.hx b/haxe/ui/macros/Macros.hx index fb785fa60..f211ea37f 100644 --- a/haxe/ui/macros/Macros.hx +++ b/haxe/ui/macros/Macros.hx @@ -647,14 +647,14 @@ class Macros { if (f.name == valueField) { if (f.isDynamic == true) { newField = builder.addSetter(f.name, f.type, macro { // add a normal (Variant) setter but let the binding manager know that the value has changed - behaviours.setDynamic($v{f.name}, value); + if (behaviours != null) behaviours.setDynamic($v{f.name}, value); dispatch(new haxe.ui.events.UIEvent(haxe.ui.events.UIEvent.PROPERTY_CHANGE, $v{f.name})); dispatch(new haxe.ui.events.UIEvent(haxe.ui.events.UIEvent.PROPERTY_CHANGE, "value")); return value; }, f.access); } else { newField = builder.addSetter(f.name, f.type, macro { // add a normal (Variant) setter but let the binding manager know that the value has changed - behaviours.set($v{f.name}, value); + if (behaviours != null) behaviours.set($v{f.name}, value); dispatch(new haxe.ui.events.UIEvent(haxe.ui.events.UIEvent.PROPERTY_CHANGE, $v{f.name})); dispatch(new haxe.ui.events.UIEvent(haxe.ui.events.UIEvent.PROPERTY_CHANGE, "value")); return value; @@ -664,7 +664,7 @@ class Macros { } else { if (f.isDynamic == true) { newField = builder.addSetter(f.name, f.type, macro { // add a normal (Variant) setter - behaviours.setDynamic($v{f.name}, value); + if (behaviours != null) behaviours.setDynamic($v{f.name}, value); dispatch(new haxe.ui.events.UIEvent(haxe.ui.events.UIEvent.PROPERTY_CHANGE, $v{f.name})); return value; }, f.access);