GUI: mark modified when replacing instruments

This commit is contained in:
tildearrow 2024-11-14 15:03:56 -05:00
parent 725c463c25
commit 3ca9545b1e

View file

@ -5418,22 +5418,15 @@ bool FurnaceGUI::loop() {
} }
break; break;
} }
case GUI_FILE_SAMPLE_OPEN_REPLACE: case GUI_FILE_SAMPLE_OPEN_REPLACE: {
{
std::vector<DivSample*> samples=e->sampleFromFile(copyOfName.c_str()); std::vector<DivSample*> samples=e->sampleFromFile(copyOfName.c_str());
if (samples.empty()) if (samples.empty()) {
{
showError(e->getLastError()); showError(e->getLastError());
} } else {
else if ((int)samples.size()==1) {
{ if (curSample>=0 && curSample<(int)e->song.sample.size()) {
if((int)samples.size() == 1)
{
if (curSample>=0 && curSample<(int)e->song.sample.size())
{
DivSample* s=samples[0]; DivSample* s=samples[0];
e->lockEngine([this, s]() e->lockEngine([this,s]() {
{
// if it crashes here please tell me... // if it crashes here please tell me...
DivSample* oldSample=e->song.sample[curSample]; DivSample* oldSample=e->song.sample[curSample];
e->song.sample[curSample]=s; e->song.sample[curSample]=s;
@ -5442,15 +5435,11 @@ bool FurnaceGUI::loop() {
MARK_MODIFIED; MARK_MODIFIED;
}); });
updateSampleTex=true; updateSampleTex=true;
} } else {
else
{
showError(_("...but you haven't selected a sample!")); showError(_("...but you haven't selected a sample!"));
delete samples[0]; delete samples[0];
} }
} } else {
else
{
for (DivSample* s: samples) { // ask which samples to load! for (DivSample* s: samples) { // ask which samples to load!
pendingSamples.push_back(std::make_pair(s,false)); pendingSamples.push_back(std::make_pair(s,false));
} }
@ -5540,6 +5529,7 @@ bool FurnaceGUI::loop() {
int instrumentCount=-1; int instrumentCount=-1;
for (DivInstrument* i: instruments) { for (DivInstrument* i: instruments) {
instrumentCount=e->addInstrumentPtr(i); instrumentCount=e->addInstrumentPtr(i);
MARK_MODIFIED;
} }
if (instrumentCount>=0 && settings.selectAssetOnLoad) { if (instrumentCount>=0 && settings.selectAssetOnLoad) {
curIns=instrumentCount-1; curIns=instrumentCount-1;
@ -5567,6 +5557,7 @@ bool FurnaceGUI::loop() {
} else { // replace with the only instrument } else { // replace with the only instrument
if (curIns>=0 && curIns<(int)e->song.ins.size()) { if (curIns>=0 && curIns<(int)e->song.ins.size()) {
*e->song.ins[curIns]=*instruments[0]; *e->song.ins[curIns]=*instruments[0];
MARK_MODIFIED;
} else { } else {
showError(_("...but you haven't selected an instrument!")); showError(_("...but you haven't selected an instrument!"));
} }