mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-01 18:42:40 +00:00
Out of bounds checking and crash fix
This commit is contained in:
parent
4bd0dc2c63
commit
c634f20d05
1 changed files with 12 additions and 0 deletions
|
@ -1235,9 +1235,12 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
ImGui::OpenPopup("SXFadeOpt");
|
||||
}
|
||||
if (ImGui::BeginPopupContextItem("SXFadeÓpt",ImGuiPopupFlags_MouseButtonLeft)) {
|
||||
if (sampleXFadeLoopLength>sample->loopStart) sampleXFadeLoopLength=sample->loopStart;
|
||||
if (sampleXFadeLoopLength>(sample->loopEnd-sample->loopStart)) sampleXFadeLoopLength=sample->loopEnd-sample->loopStart;
|
||||
if (ImGui::SliderInt("Number of samples", &sampleXFadeLoopLength, 0, 100000)) {
|
||||
if (sampleXFadeLoopLength<0) sampleXFadeLoopLength=0;
|
||||
if (sampleXFadeLoopLength>sample->loopStart) sampleXFadeLoopLength=sample->loopStart;
|
||||
if (sampleXFadeLoopLength>(sample->loopEnd-sample->loopStart)) sampleXFadeLoopLength=sample->loopEnd-sample->loopStart;
|
||||
if (sampleXFadeLoopLength>100000) sampleXFadeLoopLength=100000;
|
||||
}
|
||||
if (ImGui::SliderInt("Linear <-> Equal power", &sampleXFadeLoopLaw, 0, 100000)) {
|
||||
|
@ -1245,6 +1248,14 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
if (sampleXFadeLoopLaw>100000) sampleXFadeLoopLaw=100000;
|
||||
}
|
||||
if (ImGui::Button("Apply")) {
|
||||
if (sampleXFadeLoopLength>sample->loopStart){
|
||||
SAMPLE_WARN(warnLoop,"Crossfade: length would go out of bounds. Aborted...");
|
||||
goto done;
|
||||
}
|
||||
if (sampleXFadeLoopLength>(sample->loopEnd-sample->loopStart)) {
|
||||
SAMPLE_WARN(warnLoop,"Crossfade: length would overflow loopStart. Try a smaller random value.");
|
||||
goto done;
|
||||
}
|
||||
sample->prepareUndo(true);
|
||||
e->lockEngine([this,sample]{
|
||||
SAMPLE_OP_BEGIN;
|
||||
|
@ -1278,6 +1289,7 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
e->renderSamples(curSample);
|
||||
});
|
||||
MARK_MODIFIED;
|
||||
done:
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
|
|
Loading…
Reference in a new issue