Skip to content

Stop mutating dirLocation while importing CAD files#157

Merged
maureeungaro merged 1 commit into
gemc:mainfrom
zhaozhiwen:fix/110-cad-dirlocation-mutation
Jun 13, 2026
Merged

Stop mutating dirLocation while importing CAD files#157
maureeungaro merged 1 commit into
gemc:mainfrom
zhaozhiwen:fix/110-cad-dirlocation-mutation

Conversation

@zhaozhiwen

Copy link
Copy Markdown
Collaborator

The STL import loop used dirLocation.append("/").append(cf), which mutates dirLocation in place. After the first file, dirLocation was no longer the directory path — the second iteration produced paths like .../dir/a.stl/b.stl, so only the first STL resolved. The mangled value also leaked to the next line, where the per-variation cad__<variation>.yaml modifier path is built, so that override file was never found.

Use non-mutating concatenation (dirLocation + "/" + cf) so dirLocation stays the directory path for every file and for the YAML lookup.

Validation: compiles clean (Geant4 11.4.1 dev container).

Fixes #110

The STL import loop used dirLocation.append("/").append(cf), which
mutates dirLocation in place. After the first file, dirLocation was no
longer the directory path — the second iteration produced paths like
.../dir/a.stl/b.stl, so only the first STL resolved. The mangled value
also leaked to line 33, where the per-variation cad__<variation>.yaml
modifier path is built, so that override file was never found.

Use non-mutating concatenation (dirLocation + "/" + cf) so dirLocation
stays the directory path for every file and for the YAML lookup.

Fixes gemc#110

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@maureeungaro maureeungaro merged commit 410a6be into gemc:main Jun 13, 2026
30 checks passed
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.

[High] Fix CAD loader mutating dirLocation in-place inside the per-file loop

2 participants