Skip to content

Commit

Permalink
Fixed crash if opened odf had divisional that referenced a tremulant …
Browse files Browse the repository at this point in the history
…or switch with a number higher than available on the owning manual.
  • Loading branch information
larspalo committed May 22, 2024
1 parent fb79300 commit 79723aa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Option to create new panel from selection on existing panel display.
- Option to duplicate an existing panel.
- Option to create new panel from selection on existing panel display. (TODO)
- Option to duplicate an existing panel. (TODO)
- Option to load pipe samples with Pipe999IsTremulant value set to be played, if the associated wave-based tremulant is off. (TODO)

## [0.12.2] - 2024-05-22

### Changed

Expand All @@ -23,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Setter element labels retain their naming identification from type in the tree.
- Clicking on a GUI Element on the panel representation view should only select the uppermost element and not all underlying elements too.
- Display first key of a manual as a whole even if not an E or B provided second key is displayed as a natural.
- Crash and add log entries if divisional referenced a tremulant or switch number higher than available on the manual in question.

## [0.12.1] - 2024-05-08

Expand Down
30 changes: 20 additions & 10 deletions src/Divisional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,17 @@ void Divisional::read(wxFileConfig *cfg, bool usingOldPanelFormat, Manual *ownin
wxString tremId = cfg->Read(tremNbr, wxEmptyString);
long value = 0;
if (tremId.ToLong(&value)) {
if (value > 0) {
// the tremulant is on
m_tremulants.push_back(std::make_pair(m_owningManual->getTremulantAt(value - 1), true));
if (labs(value) <= (int) m_owningManual->getNumberOfTremulants()) {
if (value > 0) {
// the tremulant is on
m_tremulants.push_back(std::make_pair(m_owningManual->getTremulantAt(value - 1), true));
} else {
// the tremulant is off
m_tremulants.push_back(std::make_pair(m_owningManual->getTremulantAt(labs(value) - 1), false));
}
} else {
// the tremulant is off
m_tremulants.push_back(std::make_pair(m_owningManual->getTremulantAt(labs(value) - 1), false));
wxLogError("%s value %s is out of range for divisional '%s' since manual '%s' only lists %u tremulants!", tremNbr, tremId, name, m_owningManual->getName(), m_owningManual->getNumberOfTremulants());
::wxGetApp().m_frame->GetLogWindow()->Show(true);
}
}
}
Expand All @@ -153,12 +158,17 @@ void Divisional::read(wxFileConfig *cfg, bool usingOldPanelFormat, Manual *ownin
wxString swId = cfg->Read(swNbr, wxEmptyString);
long value = 0;
if (swId.ToLong(&value)) {
if (value > 0) {
// the switch is on
m_switches.push_back(std::make_pair(m_owningManual->getGoSwitchAt(value - 1), true));
if (labs(value) <= (int) m_owningManual->getNumberOfGoSwitches()) {
if (value > 0) {
// the switch is on
m_switches.push_back(std::make_pair(m_owningManual->getGoSwitchAt(value - 1), true));
} else {
// the switch is off
m_switches.push_back(std::make_pair(m_owningManual->getGoSwitchAt(labs(value) - 1), false));
}
} else {
// the switch is off
m_switches.push_back(std::make_pair(m_owningManual->getGoSwitchAt(labs(value) - 1), false));
wxLogError("%s value %s is out of range for divisional '%s' since manual '%s' only lists %u switches!", swNbr, swId, name, m_owningManual->getName(), m_owningManual->getNumberOfGoSwitches());
::wxGetApp().m_frame->GetLogWindow()->Show(true);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.1
0.12.2

0 comments on commit 79723aa

Please sign in to comment.