From 70175acaf453c5d96557c8ad138dd90d573dfe38 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 26 Aug 2020 21:39:57 -0400 Subject: [PATCH] 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. --- src/SampleBlock.h | 2 ++ src/SqliteSampleBlock.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/SampleBlock.h b/src/SampleBlock.h index 42b713a9b..0ff536609 100644 --- a/src/SampleBlock.h +++ b/src/SampleBlock.h @@ -58,8 +58,10 @@ public: virtual size_t GetSampleCount() const = 0; + //! Non-throwing, should fill with zeroes on failure virtual bool GetSummary256(float *dest, size_t frameoffset, size_t numframes) = 0; + //! Non-throwing, should fill with zeroes on failure virtual bool GetSummary64k(float *dest, size_t frameoffset, size_t numframes) = 0; diff --git a/src/SqliteSampleBlock.cpp b/src/SqliteSampleBlock.cpp index 407f88802..3173a1052 100644 --- a/src/SqliteSampleBlock.cpp +++ b/src/SqliteSampleBlock.cpp @@ -385,12 +385,21 @@ bool SqliteSampleBlock::GetSummary(float *dest, sqlite3_stmt *stmt, 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, stmt, 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