From 4e852ae4078ba453ce6b77464e4c8d8c7bca0d5f Mon Sep 17 00:00:00 2001 From: MattEqualsCoder Date: Mon, 7 Oct 2024 07:23:55 -0400 Subject: [PATCH] Fix crash with swapping tracks --- MSUScripter/MSUScripter.csproj | 2 +- .../Services/ControlServices/CopyMoveTrackWindowService.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MSUScripter/MSUScripter.csproj b/MSUScripter/MSUScripter.csproj index 5357760..56936ac 100644 --- a/MSUScripter/MSUScripter.csproj +++ b/MSUScripter/MSUScripter.csproj @@ -8,7 +8,7 @@ true MSUScripterIcon.ico MSUScripterIcon.ico - 4.1.0 + 4.1.1 8.0.0 false 12 diff --git a/MSUScripter/Services/ControlServices/CopyMoveTrackWindowService.cs b/MSUScripter/Services/ControlServices/CopyMoveTrackWindowService.cs index 1b6a6bd..1424f03 100644 --- a/MSUScripter/Services/ControlServices/CopyMoveTrackWindowService.cs +++ b/MSUScripter/Services/ControlServices/CopyMoveTrackWindowService.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -65,8 +66,8 @@ public void RunCopyMove() var swapSong = destinationTrack.Songs[_model.TargetLocation]; previousTrack.Songs.Remove(songInfo); destinationTrack.Songs.Remove(swapSong); - previousTrack.Songs.Insert(originalIndex, swapSong); - destinationTrack.Songs.Insert(_model.TargetLocation, songInfo); + previousTrack.Songs.Insert(Math.Clamp(originalIndex, 0, previousTrack.Songs.Count), swapSong); + destinationTrack.Songs.Insert(Math.Clamp(_model.TargetLocation, 0, destinationTrack.Songs.Count), songInfo); } previousTrack.FixTrackSuffixes(songInfo.CanPlaySongs);