Skip to content

fix(core): clone state deep copy#15947

Open
rc-swag wants to merge 5 commits into
fix/windows/15857/caps-indicator-switched-off-selectfrom
fix/windows/clone-state-deep-copy
Open

fix(core): clone state deep copy#15947
rc-swag wants to merge 5 commits into
fix/windows/15857/caps-indicator-switched-off-selectfrom
fix/windows/clone-state-deep-copy

Conversation

@rc-swag
Copy link
Copy Markdown
Contributor

@rc-swag rc-swag commented May 12, 2026

The api call km_core_state_clone which uses the copy constructor for the state which performed a shallow copy of _action_struct.
This would cause a free to be called on allready freed memory when disposing of the clone state object. This was discovered when updating the code to intialise the _action_struct in the constructor of the state class.

This change adds adds a deep copy and adds helper functions to actions, and options class to achieve the copy.
Adds test assertions verifying that original and cloned states have independent action_struct values.

In review of this it was noted there was an existing issue with _actions list. The actions->options are going to be point to the the original _option_items_stack vector. In practice this is unlikely to cause problems because _actions cleared and rebuilt on the next km_core_process_event call. I made the change to the core code this PR#15961 however it needs unit testing for it to be complete.

The unit test tests the clone call. It is not currenlty in used in implmentation therefore there are no manual tests available.
Test-bot: skip

This commit update the state object to have a deep copy for the
action_struct member. The tests have been modified but have
a few issues however this branch is out of date with the refacted
master branch for unit tests. This commit gets the main change in
a future commit will update the tests.
@github-project-automation github-project-automation Bot moved this to Todo in Keyman May 12, 2026
@keymanapp-test-bot keymanapp-test-bot Bot added the user-test-missing User tests have not yet been defined for the PR label May 12, 2026
@keymanapp-test-bot
Copy link
Copy Markdown

keymanapp-test-bot Bot commented May 12, 2026

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

  • macOS
    • Keyman for macOS - build : all tests passed (no artifacts on BuildLevel "build")
    • Keyman for macOS (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
  • Web
    • KeymanWeb Test Home - build : all tests passed (no artifacts on BuildLevel "build")
  • Windows
    • Keyman for Windows - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for Windows - build : all tests passed (no artifacts on BuildLevel "build")
    • FirstVoices Keyboards for Windows (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • Keyman for Windows (old PRs) - build : all tests passed (no artifacts on BuildLevel "build")
    • Text Editor (ARM64) - build : all tests passed (no artifacts on BuildLevel "build")
    • Text Editor (x64) - build : all tests passed (no artifacts on BuildLevel "build")
    • Text Editor (x86) - build : all tests passed (no artifacts on BuildLevel "build")

@keymanapp-test-bot keymanapp-test-bot Bot added this to the A19S29 milestone May 12, 2026
@rc-swag rc-swag changed the base branch from master to fix/windows/15857/caps-indicator-switched-off-select May 12, 2026 08:09
@rc-swag rc-swag changed the title fix(windows): clone state deep copy fix(core): clone state deep copy May 14, 2026
@rc-swag rc-swag requested review from ermshiperete, mcdurdin and sgschantz and removed request for mcdurdin May 18, 2026 11:25
@keymanapp-test-bot keymanapp-test-bot Bot removed the user-test-missing User tests have not yet been defined for the PR label May 18, 2026
@rc-swag rc-swag marked this pull request as ready for review May 18, 2026 11:27
Copy link
Copy Markdown
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; note that the test will be a bit painful to merge with epic/web-core because that has the gtest rewrite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants