Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Plain Craft Launcher 2/Modules/Base/ModLoader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.VisualBasic.CompilerServices;
using PCL.Core.App;
using PCL.Core.Utils;
using System.Collections;
Expand Down Expand Up @@ -43,8 +43,7 @@ public static void LoaderTaskbarProgressRefresh()
var newProgress = LoaderTaskbarProgressGet();
// 若单个任务已中止,或全部任务已完成,则刷新并移除

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: 该注释表示只有在某个任务中止或所有任务都完成时才会移除任务,但新条件会移除任何不是 Loading 状态的单个任务,包括其他任务仍处于活动状态时的 WaitingFailedFinished 任务。该注释现在错误地描述了方法的行为。

建议修复: 更新注释,说明每个非 Loading 状态的任务都会被刷新并移除。

Original comment in English

nitpick: The comment says tasks are removed only when one task is aborted or all tasks are complete, but the new condition removes any individual task that is not Loading, including Waiting, Failed, and Finished tasks while other tasks remain active. The comment now gives an incorrect description of the method's behavior.

Suggested fix: Update the comment to state that every non-Loading task is refreshed and removed.

foreach (var Task in loaderTaskbar)
if (loaderTaskbar.All(l => l.State != ModBase.LoadState.Loading) ||
Task.State == ModBase.LoadState.Waiting || Task.State == ModBase.LoadState.Aborted)
if (Task.State != ModBase.LoadState.Loading)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve failed tasks while other tasks are running

When one task fails while another remains loading and the task-manager page has not yet been opened, this condition removes the failed task immediately and frmSpeedLeft?.TaskRefresh(Task) is a no-op because that page is created lazily. Opening the manager through the still-visible download button then shows only the remaining task, so the failed task's error details cannot be inspected or copied. Previously, failed tasks remained in loaderTaskbar until no task was loading; restrict the new early-removal behavior to successfully finished tasks while retaining the existing handling for failures.

Useful? React with 👍 / 👎.

{
ModMain.frmSpeedLeft?.TaskRefresh(Task);
loaderTaskbar.Remove(Task);
Comment on lines 43 to 49

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): newProgress 在已完成任务被移除之前根据 loaderTaskbar 计算,因此进度更新会包含那些已经不再被跟踪的终止状态任务。当一个已完成任务的进度为 1,而剩余任务的进度较低时,任务栏进度会在本次刷新时被高估,并且平滑状态会根据错误的任务集合进行更新。

触发条件: 当一个任务完成时,其他任务栏任务仍在加载且它们的进度不同时。

建议修复: 在计算 LoaderTaskbarProgressGet() 之前移除非加载状态的任务,或者在移除循环之后重新计算 newProgress

Suggested change
var newProgress = LoaderTaskbarProgressGet();
// 若单个任务已中止,或全部任务已完成,则刷新并移除
foreach (var Task in loaderTaskbar)
if (loaderTaskbar.All(l => l.State != ModBase.LoadState.Loading) ||
Task.State == ModBase.LoadState.Waiting || Task.State == ModBase.LoadState.Aborted)
if (Task.State != ModBase.LoadState.Loading)
{
ModMain.frmSpeedLeft?.TaskRefresh(Task);
loaderTaskbar.Remove(Task);
// 若单个任务已中止,或全部任务已完成,则刷新并移除
foreach (var Task in loaderTaskbar)
if (Task.State != ModBase.LoadState.Loading)
{
ModMain.frmSpeedLeft?.TaskRefresh(Task);
loaderTaskbar.Remove(Task);
ModBase.Log($"[Taskbar] {Task.name} 已移出任务列表");
}
var newProgress = LoaderTaskbarProgressGet();
Original comment in English

issue (bug_risk): newProgress is calculated from loaderTaskbar before completed tasks are removed, so the progress update includes terminal tasks that are no longer tracked. When a completed task has progress 1 and a remaining task has lower progress, the taskbar progress is overstated for the refresh tick and the smoothing state is updated from the wrong task set.

Triggers: When one task completes while other taskbar tasks are still loading and their progress differs.

Suggested fix: Remove non-loading tasks before calculating LoaderTaskbarProgressGet(), or recalculate newProgress after the removal loop.

Suggested change
var newProgress = LoaderTaskbarProgressGet();
// 若单个任务已中止,或全部任务已完成,则刷新并移除
foreach (var Task in loaderTaskbar)
if (loaderTaskbar.All(l => l.State != ModBase.LoadState.Loading) ||
Task.State == ModBase.LoadState.Waiting || Task.State == ModBase.LoadState.Aborted)
if (Task.State != ModBase.LoadState.Loading)
{
ModMain.frmSpeedLeft?.TaskRefresh(Task);
loaderTaskbar.Remove(Task);
// 若单个任务已中止,或全部任务已完成,则刷新并移除
foreach (var Task in loaderTaskbar)
if (Task.State != ModBase.LoadState.Loading)
{
ModMain.frmSpeedLeft?.TaskRefresh(Task);
loaderTaskbar.Remove(Task);
ModBase.Log($"[Taskbar] {Task.name} 已移出任务列表");
}
var newProgress = LoaderTaskbarProgressGet();

Expand Down