1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-05 16:43:52 +01:00

Fix infinite loop of error messages trying to draw corrupt project...

... As reported by Steve.

Don't throw exceptions when trying only to display a track and the samples
can't be found in the database.
This commit is contained in:
Paul Licameli
2020-08-26 21:39:57 -04:00
parent 2389b191f6
commit 70175acaf4
2 changed files with 13 additions and 2 deletions

View File

@@ -58,8 +58,10 @@ public:
virtual size_t GetSampleCount() const = 0; virtual size_t GetSampleCount() const = 0;
//! Non-throwing, should fill with zeroes on failure
virtual bool virtual bool
GetSummary256(float *dest, size_t frameoffset, size_t numframes) = 0; GetSummary256(float *dest, size_t frameoffset, size_t numframes) = 0;
//! Non-throwing, should fill with zeroes on failure
virtual bool virtual bool
GetSummary64k(float *dest, size_t frameoffset, size_t numframes) = 0; GetSummary64k(float *dest, size_t frameoffset, size_t numframes) = 0;

View File

@@ -385,12 +385,21 @@ bool SqliteSampleBlock::GetSummary(float *dest,
sqlite3_stmt *stmt, sqlite3_stmt *stmt,
size_t srcbytes) size_t srcbytes)
{ {
return GetBlob(dest, // Non-throwing, it returns true for success
try {
// Note GetBlob returns a size_t, not a bool
GetBlob(dest,
floatSample, floatSample,
stmt, stmt,
floatSample, floatSample,
frameoffset * 3 * SAMPLE_SIZE(floatSample), frameoffset * 3 * SAMPLE_SIZE(floatSample),
numframes * 3 * SAMPLE_SIZE(floatSample)) / 3 / SAMPLE_SIZE(floatSample); numframes * 3 * SAMPLE_SIZE(floatSample));
return true;
}
catch ( const AudacityException & ) {
memset(dest, 0, 3 * numframes * sizeof( float ));
return false;
}
} }
double SqliteSampleBlock::GetSumMin() const double SqliteSampleBlock::GetSumMin() const