Fix edge case when region start is after the source' end

This fixes an edge case where an audio-region was split near
its end using music-time.

see also 7ded62c37f
This commit is contained in:
Robin Gareus 2025-09-21 17:52:49 +02:00
parent 72eda5e98f
commit 36ed5bbf37
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -1574,8 +1574,14 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang
non-silently just force the region length to the non-silently just force the region length to the
correct value. correct value.
*/ */
error << "Correcting length of region " << _name << " to match it's (first) source's length of " << _sources.front()->length().str() << endmsg; error << "Correcting region " << _name << " with start offset " << start() << " length " << _length << " to match it's (first) source's length of " << _sources.front()->length().str() << endmsg;
_length = timecnt_t (start().distance (_sources.front()->length()), _length.val().position()); if (start() >= _sources.front()->length()) {
_length = timecnt_t (0, _length.val().position());
error << "Truncated region " << _name << " length to " << _length << endmsg;
} else {
_length = timecnt_t (start().distance (_sources.front()->length()), _length.val().position());
error << "Corrected region " << _name << " length to " << _length << endmsg;
}
} }
} }