From e6becb342553ee3197a2f4cf3e23f1118d91383b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 7 Jun 2010 12:44:15 +0000 Subject: Better-define behaviour when relayering a playlist with a single zero-length region. Fixes #3144. git-svn-id: svn://localhost/ardour2/branches/3.0@7238 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/playlist.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 2044a2f142..bab4e358f9 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -2432,14 +2432,22 @@ Playlist::relayer () /* reset the pending explicit relayer flag for every region, now that we're relayering */ (*i)->set_pending_explicit_relayer (false); - /* find the time divisions that this region covers */ - int const start_division = floor ( ((*i)->position() - start) / division_size); - int end_division = floor ( ((*i)->position() + (*i)->length() - start) / division_size ); - if (end_division == divisions) { - end_division--; + /* find the time divisions that this region covers; if there are no regions on the list, + division_size will equal 0 and in this case we'll just say that + start_division = end_division = 0. + */ + int start_division = 0; + int end_division = 0; + + if (division_size > 0) { + start_division = floor ( ((*i)->position() - start) / division_size); + end_division = floor ( ((*i)->position() + (*i)->length() - start) / division_size ); + if (end_division == divisions) { + end_division--; + } } - assert (end_division < divisions); + assert (divisions == 0 || end_division < divisions); /* find the lowest layer that this region can go on */ size_t j = layers.size(); -- cgit v1.2.3