Skip to content

Commit

Permalink
Fix number stepper crash from locale event not being unregistered aft…
Browse files Browse the repository at this point in the history
…er being disposed
  • Loading branch information
Starmapo committed Aug 25, 2024
1 parent 23b4a17 commit 580087f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions haxe/ui/components/NumberStepper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private class Events extends haxe.ui.events.Events {
_stepper.unregisterEvent(FocusEvent.FOCUS_IN, onFocusIn);
_stepper.unregisterEvent(FocusEvent.FOCUS_OUT, onFocusOut);
_stepper.unregisterEvent(MouseEvent.MOUSE_WHEEL, onMouseWheel);
LocaleManager.instance.unregisterEvent(LocaleEvent.LOCALE_CHANGED, onLocaleChanged);
removeLocaleChanged();

var value:TextField = _stepper.findComponent("value", TextField);
value.unregisterEvent(UIEvent.CHANGE, onValueFieldChange);
Expand All @@ -268,7 +268,17 @@ private class Events extends haxe.ui.events.Events {
inc.unregisterEvent(MouseEvent.CLICK, onInc);
unregisterEvent(ActionEvent.ACTION_START, onActionStart);
}


public override function onDispose() {
// `unregister()` isn't called when the component is disposed,
// so this listener would be left lingering
removeLocaleChanged();
}

private function removeLocaleChanged() {
LocaleManager.instance.unregisterEvent(LocaleEvent.LOCALE_CHANGED, onLocaleChanged);
}

private var _autoCorrectTimer:Timer = null;
private function onValueFieldChange(event:UIEvent) {
if (_stepper.autoCorrect == true) {
Expand Down

0 comments on commit 580087f

Please sign in to comment.