Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): make debug list management more robust #10920

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
Loading