mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-24 23:33:50 +02:00
All the catches are in place for BlockFile and other errors, now throw.
This commit is contained in:
@@ -441,8 +441,7 @@ void Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
// PRL: Why bother with Internat when the above is just wxT?
|
||||
Internat::ToString(s.as_double(), 0).c_str(),
|
||||
Internat::ToString(mNumSamples.as_double(), 0).c_str());
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
}
|
||||
|
||||
// Quick check to make sure that it doesn't overflow
|
||||
@@ -453,8 +452,7 @@ void Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
// PRL: Why bother with Internat when the above is just wxT?
|
||||
Internat::ToString(mNumSamples.as_double(), 0).c_str(),
|
||||
Internat::ToString(src->mNumSamples.as_double(), 0).c_str());
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
}
|
||||
|
||||
if (src->mSampleFormat != mSampleFormat)
|
||||
@@ -462,8 +460,7 @@ void Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
wxLogError(
|
||||
wxT("Sequence::Paste: Sample format to be pasted, %s, does not match destination format, %s."),
|
||||
GetSampleFormatStr(src->mSampleFormat), GetSampleFormatStr(src->mSampleFormat));
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
}
|
||||
|
||||
const BlockArray &srcBlock = src->mBlock;
|
||||
@@ -607,11 +604,7 @@ void Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
for (i = 2; i < srcNumBlocks - 2; i++) {
|
||||
const SeqBlock &block = srcBlock[i];
|
||||
auto file = mDirManager->CopyBlockFile(block.f);
|
||||
if (!file) {
|
||||
wxASSERT(false); // TODO: Handle this better, alert the user of failure.
|
||||
return;
|
||||
}
|
||||
|
||||
// We can assume file is not null
|
||||
newBlock.push_back(SeqBlock(file, block.start + s));
|
||||
}
|
||||
|
||||
@@ -645,8 +638,7 @@ void Sequence::InsertSilence(sampleCount s0, sampleCount len)
|
||||
{
|
||||
// Quick check to make sure that it doesn't overflow
|
||||
if (Overflows((mNumSamples.as_double()) + (len.as_double())))
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
|
||||
if (len <= 0)
|
||||
return;
|
||||
@@ -696,8 +688,7 @@ void Sequence::AppendAlias(const wxString &fullPath,
|
||||
{
|
||||
// Quick check to make sure that it doesn't overflow
|
||||
if (Overflows((mNumSamples.as_double()) + ((double)len)))
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
|
||||
SeqBlock newBlock(
|
||||
useOD?
|
||||
@@ -715,8 +706,7 @@ void Sequence::AppendCoded(const wxString &fName, sampleCount start,
|
||||
{
|
||||
// Quick check to make sure that it doesn't overflow
|
||||
if (Overflows((mNumSamples.as_double()) + ((double)len)))
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
|
||||
SeqBlock newBlock(
|
||||
mDirManager->NewODDecodeBlockFile(fName, start, len, channel, decodeType),
|
||||
@@ -732,19 +722,13 @@ void Sequence::AppendBlock
|
||||
{
|
||||
// Quick check to make sure that it doesn't overflow
|
||||
if (Overflows((mNumSamples.as_double()) + ((double)b.f->GetLength())))
|
||||
// THROW_INCONSISTENCY_EXCEPTION
|
||||
return
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
|
||||
SeqBlock newBlock(
|
||||
mDirManager.CopyBlockFile(b.f), // Bump ref count if not locked, else copy
|
||||
mNumSamples
|
||||
);
|
||||
if (!newBlock.f) {
|
||||
/// \todo Error Could not paste! (Out of disk space?)
|
||||
wxASSERT(false); // TODO: Handle this better, alert the user of failure.
|
||||
return;
|
||||
}
|
||||
// We can assume newBlock.f is not null
|
||||
|
||||
mBlock.push_back(newBlock);
|
||||
mNumSamples += newBlock.f->GetLength();
|
||||
@@ -1137,8 +1121,7 @@ bool Sequence::Get(samplePtr buffer, sampleFormat format,
|
||||
if (start < 0 || start > mNumSamples ||
|
||||
start + len > mNumSamples) {
|
||||
if (mayThrow)
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
ClearSamples( buffer, floatSample, 0, len );
|
||||
return false;
|
||||
}
|
||||
@@ -1176,8 +1159,7 @@ void Sequence::SetSamples(samplePtr buffer, sampleFormat format,
|
||||
{
|
||||
if (start < 0 || start >= mNumSamples ||
|
||||
start + len > mNumSamples)
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
|
||||
SampleBuffer scratch(mMaxSamples, mSampleFormat);
|
||||
|
||||
@@ -1213,9 +1195,7 @@ void Sequence::SetSamples(samplePtr buffer, sampleFormat format,
|
||||
|
||||
if (!(fileLength <= mMaxSamples &&
|
||||
bstart + blen <= fileLength))
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
wxASSERT(false)
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
|
||||
if ( bstart > 0 || blen < fileLength ) {
|
||||
Read(scratch.ptr(), mSampleFormat, block, 0, fileLength, true);
|
||||
@@ -1527,8 +1507,7 @@ void Sequence::Append(samplePtr buffer, sampleFormat format,
|
||||
|
||||
// Quick check to make sure that it doesn't overflow
|
||||
if (Overflows(mNumSamples.as_double() + ((double)len)))
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
|
||||
BlockArray newBlock;
|
||||
sampleCount newNumSamples = mNumSamples;
|
||||
@@ -1644,8 +1623,7 @@ void Sequence::Delete(sampleCount start, sampleCount len)
|
||||
return;
|
||||
|
||||
if (len < 0 || start < 0 || start >= mNumSamples)
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
THROW_INCONSISTENCY_EXCEPTION;
|
||||
|
||||
//TODO: add a ref-deref mechanism to SeqBlock/BlockArray so we don't have to make this a critical section.
|
||||
//On-demand threads iterate over the mBlocks and the GUI thread deletes them, so for now put a mutex here over
|
||||
@@ -1858,8 +1836,7 @@ void Sequence::ConsistencyCheck
|
||||
wxT("Undo the failed operation(s), then export or save your work and quit."));
|
||||
|
||||
if (mayThrow)
|
||||
//throw ex
|
||||
;
|
||||
throw ex;
|
||||
else
|
||||
wxASSERT(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user