Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed loading an organ when some configuration entry is out of range https://github.com/GrandOrgue/grandorgue/issues/1696 #1707

Merged
merged 2 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixed loading an organ when some configuration entry is out of range https://github.com/GrandOrgue/grandorgue/issues/1696
- Fixed crash when trying to load a sample set with a truncated wave file https://github.com/GrandOrgue/grandorgue/discussions/370
- Fixed crash on closing an organ https://github.com/GrandOrgue/grandorgue/issues/1678
# 3.13.1 (2023-11-05)
Expand Down
52 changes: 32 additions & 20 deletions src/core/config/GOConfigReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,22 @@ int GOConfigReader::ReadInteger(
value.c_str());
}

if (nmin <= retval && retval <= nmax)
return retval;

wxString error;
error.Printf(
_("Out of range value at section '%s' entry '%s': %ld"),
group,
key,
retval);
throw error;
if (retval < nmin || retval > nmax) {
if (type == ODFSetting)
throw wxString::Format(
_("Out of range value at section '%s' entry '%s': %ld"),
group,
key,
retval);
wxLogError(
_("Out of range value at section '%s' entry '%s': %ld. Assumed %d"),
group,
key,
retval,
defaultValue);
retval = defaultValue;
}
return retval;
}

int GOConfigReader::ReadLong(
Expand Down Expand Up @@ -455,16 +461,22 @@ double GOConfigReader::ReadFloat(
throw error;
}

if (nmin <= retval && retval <= nmax)
return retval;

wxString error;
error.Printf(
_("Out of range value at section '%s' entry '%s': %f"),
group.c_str(),
key.c_str(),
retval);
throw error;
if (retval < nmin || retval > nmax) {
if (type == ODFSetting)
throw wxString::Format(
_("Out of range value at section '%s' entry '%s': %f"),
group,
key,
retval);
wxLogError(
_("Out of range value at section '%s' entry '%s': %f. Assumed %f."),
group,
key,
retval,
defaultValue);
retval = defaultValue;
}
return retval;
}

unsigned GOConfigReader::ReadSize(
Expand Down