-Updated Stately, working on handling save-errors better

This commit is contained in:
Harry van Haaren 2013-11-14 13:29:22 +00:00
parent 3362995530
commit 6c014ae2a6
3 changed files with 30 additions and 14 deletions

View file

@ -62,7 +62,8 @@ void LooperClip::save()
}
else
{
Stately::done();
// notify of "success" of save if there *is* no state to save
Stately::success();
}
}
@ -149,12 +150,13 @@ void LooperClip::recieveSaveBuffer( AudioBuffer* saveBuffer )
EventStateSaveBuffer e ( track, scene, saveBuffer );
writeToGuiRingbuffer( &e );
Stately::done();
Stately::success();
}
else
{
LUPPP_ERROR("LooperClip @ %i, %i could not save, save buffer too small!", track, scene);
Stately::error();
Stately::error("");
}
}

View file

@ -6,7 +6,8 @@
extern Jack* jack;
int Stately::savesDone = 0;
int Stately::saveSuccess = 0;
int Stately::saveErrors = 0;
Stately::Stately()
{
@ -22,19 +23,27 @@ void Stately::save()
{
}
void Stately::done()
void Stately::checkCompletedSave()
{
savesDone++;
if ( savesDone >= jack->getState()->getNumStatelys() )
if ( (saveSuccess + saveErrors) >= jack->getState()->getNumStatelys() )
{
jack->getState()->finish();
savesDone = 0; // reset in case of another save before quit
// reset in case of another save before quit
saveErrors = 0;
saveSuccess = 0;
}
}
void Stately::error()
void Stately::success()
{
saveSuccess++;
checkCompletedSave();
}
void Stately::error(const char* errorString)
{
// CRITICAL FIXME: add error handling code, noting an error occured, perhaps prompt user?
savesDone++;
saveErrors++;
checkCompletedSave();
}

View file

@ -25,14 +25,19 @@ class Stately
/// this function *must* be called by each sub-class when it is *finished*
/// a successful save action. Once each Stately is done, the final save is OK-ed.
static void done();
static void success();
/// this function notes that a stately could *not* successfully save: buffer
/// size mismatch in LooperClip for example.
static void error();
static void error(const char* errorString);
private:
static int savesDone;
/// holds the amount of successful / error-full saves. Used by success()
/// and error()
static int saveSuccess;
static int saveErrors;
static void checkCompletedSave();
};
#endif // LUPPP_STATELY_H