Skip to content

fix: getPathToUseCases returns mutable global instead of frozen static local - #115

Open
SoundMatt wants to merge 1 commit into
COVESA:mainfrom
SoundMatt:fix/static-path-capture
Open

fix: getPathToUseCases returns mutable global instead of frozen static local#115
SoundMatt wants to merge 1 commit into
COVESA:mainfrom
SoundMatt:fix/static-path-capture

Conversation

@SoundMatt

Copy link
Copy Markdown

Problem

getPathToUseCases() initialises a static const std::string use_cases_path = USE_CASES_PATH on its first call. Any later call to setPathToUseCases() updates USE_CASES_PATH but the already-frozen static local is returned on every subsequent call, making the setter silently a no-op after first use.

Root cause

C++ static local variables are initialised exactly once. Assigning to the module-level USE_CASES_PATH after the first call to getPathToUseCases has no effect because use_cases_path was already bound to the old value.

Fix

Remove the static const local and return USE_CASES_PATH directly. This is a one-line change that makes the getter reflect the current value of the global and allows setPathToUseCases to take effect at any time.

…c local

getPathToUseCases initialised a static const local on first call,
freezing the value of USE_CASES_PATH at that point. Any subsequent call
to setPathToUseCases updated the global but had no effect because the
already-initialised static was returned instead. Remove the static local
and return USE_CASES_PATH directly so that setPathToUseCases takes effect
on all subsequent calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant