diff options
| author | Florian Jung <flo@windfisch.org> | 2013-09-18 23:51:16 +0200 | 
|---|---|---|
| committer | Florian Jung <flo@windfisch.org> | 2013-09-18 23:51:16 +0200 | 
| commit | 85a51421d44f3893a1010f77e0418caf6be70235 (patch) | |
| tree | 83ab91e988c59076d81ebddc09e8ff274dee8af5 | |
| parent | 3af23118587ac52a88825314a97145e44e09600c (diff) | |
adjust song length always
| -rw-r--r-- | muse2/muse/undo.cpp | 25 | 
1 files changed, 25 insertions, 0 deletions
diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp index b4a2a26f..103b47ac 100644 --- a/muse2/muse/undo.cpp +++ b/muse2/muse/undo.cpp @@ -326,6 +326,9 @@ void prepareOperationGroup(Undo& group)  	QSet<const Track*> deleted_tracks;  	QSet<const Part*> deleted_parts; +	int songlen = MusEGlobal::song->len(); +	 +  	for (iUndoOp op=group.begin(); op!=group.end();)  	{  		iUndoOp op_=op; @@ -360,10 +363,32 @@ void prepareOperationGroup(Undo& group)  			else  				deleted_parts.insert(op->part);  		} +		else if (op->type==UndoOp::AddPart || op->type==UndoOp::ModifyPartLength || +		         op->type==UndoOp::ModifyPartTick) +		{ +			if (op->type==UndoOp::AddPart) +			{ +				if (songlen < op->part->endTick()) +					songlen = op->part->endTick(); +			} +			else if (op->type==UndoOp::ModifyPartTick) +			{ +				if (songlen < op->new_partlen_or_tick+op->part->lenTick()) +					songlen = op->new_partlen_or_tick+op->part->lenTick(); +			} +			else if (op->type==UndoOp::ModifyPartLength) +			{ +				if (songlen < op->part->tick()+op->new_partlen_or_tick) +					songlen=op->part->tick()+op->new_partlen_or_tick; +			} +		}  		op=op_;  	} +	if (songlen >= MusEGlobal::song->len()) +		group.push_back(UndoOp(UndoOp::ModifySongLen, songlen, MusEGlobal::song->len())); +	  	// replicate Event modifications to keep clones up to date.  	// do not replicate SelectEvent because... umm, it just doesn't feel right.  	for (iUndoOp op=group.begin(); op!=group.end(); op++)  | 
