mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 06:53:01 +00:00
fix crash when loading instrument with samples
This commit is contained in:
parent
1a31b80ea6
commit
82649c9c81
1 changed files with 16 additions and 0 deletions
|
@ -1474,8 +1474,12 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
||||||
workingDirIns,
|
workingDirIns,
|
||||||
dpiScale,
|
dpiScale,
|
||||||
[this](const char* path) {
|
[this](const char* path) {
|
||||||
|
int sampleCountBefore=e->song.sampleLen;
|
||||||
std::vector<DivInstrument*> instruments=e->instrumentFromFile(path);
|
std::vector<DivInstrument*> instruments=e->instrumentFromFile(path);
|
||||||
if (!instruments.empty()) {
|
if (!instruments.empty()) {
|
||||||
|
if (e->song.sampleLen!=sampleCountBefore) {
|
||||||
|
e->renderSamplesP();
|
||||||
|
}
|
||||||
if (curFileDialog==GUI_FILE_INS_OPEN_REPLACE) {
|
if (curFileDialog==GUI_FILE_INS_OPEN_REPLACE) {
|
||||||
if (prevIns==-3) {
|
if (prevIns==-3) {
|
||||||
prevIns=curIns;
|
prevIns=curIns;
|
||||||
|
@ -3069,10 +3073,14 @@ bool FurnaceGUI::loop() {
|
||||||
break;
|
break;
|
||||||
case SDL_DROPFILE:
|
case SDL_DROPFILE:
|
||||||
if (ev.drop.file!=NULL) {
|
if (ev.drop.file!=NULL) {
|
||||||
|
int sampleCountBefore=e->song.sampleLen;
|
||||||
std::vector<DivInstrument*> instruments=e->instrumentFromFile(ev.drop.file);
|
std::vector<DivInstrument*> instruments=e->instrumentFromFile(ev.drop.file);
|
||||||
DivWavetable* droppedWave=NULL;
|
DivWavetable* droppedWave=NULL;
|
||||||
DivSample* droppedSample=NULL;;
|
DivSample* droppedSample=NULL;;
|
||||||
if (!instruments.empty()) {
|
if (!instruments.empty()) {
|
||||||
|
if (e->song.sampleLen!=sampleCountBefore) {
|
||||||
|
e->renderSamplesP();
|
||||||
|
}
|
||||||
if (!e->getWarnings().empty()) {
|
if (!e->getWarnings().empty()) {
|
||||||
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||||
}
|
}
|
||||||
|
@ -4160,6 +4168,7 @@ bool FurnaceGUI::loop() {
|
||||||
bool ask=false;
|
bool ask=false;
|
||||||
bool warn=false;
|
bool warn=false;
|
||||||
String warns="there were some warnings/errors while loading instruments:\n";
|
String warns="there were some warnings/errors while loading instruments:\n";
|
||||||
|
int sampleCountBefore=e->song.sampleLen;
|
||||||
for (String i: fileDialog->getFileName()) {
|
for (String i: fileDialog->getFileName()) {
|
||||||
std::vector<DivInstrument*> insTemp=e->instrumentFromFile(i.c_str());
|
std::vector<DivInstrument*> insTemp=e->instrumentFromFile(i.c_str());
|
||||||
if (insTemp.empty()) {
|
if (insTemp.empty()) {
|
||||||
|
@ -4174,6 +4183,9 @@ bool FurnaceGUI::loop() {
|
||||||
instruments.push_back(j);
|
instruments.push_back(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e->song.sampleLen!=sampleCountBefore) {
|
||||||
|
e->renderSamplesP();
|
||||||
|
}
|
||||||
if (warn) {
|
if (warn) {
|
||||||
if (instruments.empty()) {
|
if (instruments.empty()) {
|
||||||
if (fileDialog->getFileName().size()>1) {
|
if (fileDialog->getFileName().size()>1) {
|
||||||
|
@ -4203,8 +4215,12 @@ bool FurnaceGUI::loop() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GUI_FILE_INS_OPEN_REPLACE: {
|
case GUI_FILE_INS_OPEN_REPLACE: {
|
||||||
|
int sampleCountBefore=e->song.sampleLen;
|
||||||
std::vector<DivInstrument*> instruments=e->instrumentFromFile(copyOfName.c_str());
|
std::vector<DivInstrument*> instruments=e->instrumentFromFile(copyOfName.c_str());
|
||||||
if (!instruments.empty()) {
|
if (!instruments.empty()) {
|
||||||
|
if (e->song.sampleLen!=sampleCountBefore) {
|
||||||
|
e->renderSamplesP();
|
||||||
|
}
|
||||||
if (!e->getWarnings().empty()) {
|
if (!e->getWarnings().empty()) {
|
||||||
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue