Skip to content

Commit

Permalink
fix(core): make debug list management more robust
Browse files Browse the repository at this point in the history
Relates to #10915.
  • Loading branch information
mcdurdin committed Mar 4, 2024
1 parent 0d2e044 commit d7048f7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions core/src/kmx/kmx_processevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ KMX_BOOL KMX_ProcessEvent::ProcessEvent(
CreateInternalDebugItems();
} else {
// We want to have a clean debug state even if it is not in use
state->debug_items().push_end(m_actions.Length(), 0);
FinishInternalDebugItems();
}

ResetCapsLock(modifiers, isKeyDown);
Expand All @@ -106,24 +106,30 @@ KMX_BOOL KMX_ProcessEvent::ProcessEvent(

if (kbd->StartGroup[BEGIN_UNICODE] == (KMX_DWORD) -1) {
DebugLog("Non-Unicode keyboards are not supported.");
FinishInternalDebugItems();
m_core_state = nullptr;
return FALSE;
}

switch (vkey) {
case KM_CORE_VKEY_CAPS:
if (KeyCapsLockPress(modifiers, isKeyDown))
if (KeyCapsLockPress(modifiers, isKeyDown)) {
FinishInternalDebugItems();
return TRUE;
}
break;
case KM_CORE_VKEY_SHIFT:
KeyShiftPress(modifiers, isKeyDown);
FinishInternalDebugItems();
return TRUE;
case KM_CORE_VKEY_CONTROL:
case KM_CORE_VKEY_ALT:
FinishInternalDebugItems();
return TRUE;
}

if (!isKeyDown) {
FinishInternalDebugItems();
m_core_state = nullptr;
return FALSE;
}
Expand Down Expand Up @@ -793,3 +799,11 @@ void KMX_ProcessEvent::DeleteInternalDebugItems() {
}
m_options.SetInternalDebugItems(m_debug_items);
}

void KMX_ProcessEvent::FinishInternalDebugItems() {
assert(m_debug_items != nullptr);
m_debug_items->push_end(m_actions.Length(), 0);
// m_debug_items is just a helper class that pushes to state->debug_items(),
// so we can throw it away after we are done with it
DeleteInternalDebugItems();
}

0 comments on commit d7048f7

Please sign in to comment.