Skip to content

Fix S-param mode not reloading on project deserialize - #56

Merged
striderZA merged 2 commits into
masterfrom
fix/issue-44-sparam-deserialize-reload
Aug 7, 2026
Merged

Fix S-param mode not reloading on project deserialize#56
striderZA merged 2 commits into
masterfrom
fix/issue-44-sparam-deserialize-reload

Conversation

@striderZA

Copy link
Copy Markdown
Owner

Summary

Fixes #44. deserialize() in the five S-param-capable engines (Amplifier, IdealFilter, Equalizer, Attenuator, Combiner) restored sparam_mode/sparam_filepath from the project JSON but never reloaded the Touchstone file. update() gates the S-param path on sparam_mode && sparam_data.loaded(), so a reloaded project silently fell back to ideal/manual mode while the UI still showed S-param mode as enabled.

Root cause

Confirmed by reading each engine's deserialize(): the loader (m_sparam_data.load(...) / m_sparam.load(...)) was only ever invoked from the setSParamFilepath()/setSParamFile() setters used by live UI interaction — never from deserialize(), which is also the path used for project load, component cloning, and library-part instantiation.

EqualizerEngine::serialize() additionally omitted sparam_fwd_idx, which its S-param branch (equalizer_engine.cpp:51) depends on.

Fix

  • amplifier_engine.cpp, ideal_filter_engine.cpp, equalizer_engine.cpp: deserialize() now reloads m_sparam_data from the deserialized filepath and gates m_sparam_mode on the actual loaded() result (so a stale/missing file now correctly reports mode off instead of on-but-broken). sparam_fwd_idx is preserved from JSON, not recomputed.
  • attenuator_engine.cpp, combiner_engine.cpp: same pattern via m_sparam.load(...).
  • equalizer_engine.cpp serialize(): added missing sparam_fwd_idx field.

Test

Added tests/test_project_file.cpp case 13 ("Round-trip: S-param mode survives save/load (issue #44)"): builds all 5 component types in S-param mode using the existing component_data/amplifiers/adm-3844psm/*.s2p fixture, saves, reloads in a fresh RfSimulatorApp, and asserts sparamMode()/sparamLoaded()/sParamMode() are all true post-reload.

Verification

  • Full tests suite: 216 test cases, 65530 assertions — pass, no regressions
  • [project_file] filter: 12 cases, 90 assertions — pass (includes new test)
  • [sparam] filter: 12 cases, 4057 assertions — pass
  • test_attenuator.exe / test_combiner.exe — pass
  • Formatted with clang-format-18 (matches CI)

The repo-wide format job (clang-format-18) flagged pre-existing violations
carried from #42; no PR could pass until these were resolved.
@striderZA
striderZA merged commit fa4710d into master Aug 7, 2026
2 checks passed
striderZA added a commit that referenced this pull request Aug 10, 2026
… must use the local staged fixture (S1 containment neutralizes absolute out-of-project paths on load)
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.

S-param engines never reload Touchstone data on deserialize - project load silently degrades to ideal mode

1 participant