Skip to content

Commit

Permalink
Merge pull request #625 from Starmapo/fix-stepper-crash
Browse files Browse the repository at this point in the history
Fix crash from disposed number stepper
  • Loading branch information
ianharrigan authored Aug 26, 2024
2 parents 206f16d + 580087f commit aea9139
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 aea9139

Please sign in to comment.