Add null check

This commit is contained in:
Stephen Ostermiller 2025-06-28 05:46:41 -04:00
parent 693507d759
commit 24fae67788
3 changed files with 3 additions and 3 deletions

View File

@ -1,3 +1,3 @@
# Tap dance state removed from `tap_dance_action_t`
Code that accessed the tap dance state as a field in the tap dance action should now call `tap_dance_get_state(int tap_dance_idx)` instead.
Code that accessed the tap dance state as a field in the tap dance action should now call `tap_dance_get_state(int tap_dance_idx)` instead. That function may return `NULL` if many tap dance keys are held together. Add a `NULL` check before using the returned state.

View File

@ -215,7 +215,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case TD(CT_CLN):
action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(keycode));
state = tap_dance_get_state(QK_TAP_DANCE_GET_INDEX(keycode));
if (!record->event.pressed && state->count && !state->finished) {
if (!record->event.pressed && state != NULL && state->count && !state->finished) {
tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data;
tap_code16(tap_hold->tap);
}

View File

@ -87,7 +87,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case TD(CT_CLN):
action = tap_dance_get(QK_TAP_DANCE_GET_INDEX(keycode));
state = tap_dance_get_state(QK_TAP_DANCE_GET_INDEX(keycode));
if (!record->event.pressed && state->count && !state->finished) {
if (!record->event.pressed && state != NULL && state->count && !state->finished) {
tap_dance_tap_hold_t *tap_hold = (tap_dance_tap_hold_t *)action->user_data;
tap_code16(tap_hold->tap);
}