TaskManager when deleting task also remove from parent.

This commit is contained in:
glax 2023-06-15 18:24:19 +02:00
parent 93de471836
commit e789c429cd

View File

@ -193,7 +193,9 @@ public class TaskManager
{ {
logger?.WriteLine(this.GetType().ToString(), $"Removing Task {removeTask}"); logger?.WriteLine(this.GetType().ToString(), $"Removing Task {removeTask}");
_allTasks.Remove(removeTask); _allTasks.Remove(removeTask);
if (removeTask.GetType() == typeof(DownloadChapterTask)) if (removeTask.parentTask is not null)
removeTask.parentTask.RemoveChildTask(removeTask);
if (removeTask.GetType() == typeof(DownloadChapterTask) && _runningDownloadChapterTasks.ContainsKey((DownloadChapterTask)removeTask))
{ {
_runningDownloadChapterTasks[(DownloadChapterTask)removeTask].Cancel(); _runningDownloadChapterTasks[(DownloadChapterTask)removeTask].Cancel();
_runningDownloadChapterTasks.Remove((DownloadChapterTask)removeTask); _runningDownloadChapterTasks.Remove((DownloadChapterTask)removeTask);