Skip to content

Commit daf1a46

Browse files
authored
[Hotfix] Preview 1.83.5 Release (#766)
# What's changed? - **[Fix]** File sharing error on background image file, by @shatyuka - **[Fix]** Crashing during startup in certain system caused by race condition in EnableWindowNonClientArea method, by @bagusnl - **[Fix]** Incorrect per-file size if patch file has already been downloaded, by @neon-nyan - **[Fix]** NRE spam on DB initializer when DB URL/Token is empty, by @bagusnl - **[Fix]** ObjectDisposed exception rare occassion when calling DispatcherQueue.HasThreadAccess, by @bagusnl - **[Imp]** Sophon improvements, by @neon-nyan - Reduce memory overhead - Reduce timed-out occurrence when downloading objects - Adding check to include additional packages if they were installed - Only trigger full download (with additional packages) on initial installation - No dialog involved. If you need to the dialog in order to download the base file, add a blank file with name: @AskAdditionalSophonPackage in your game directory ### Templates <details> <summary>Changelog Prefixes</summary> ``` **[New]** **[Imp]** **[Fix]** **[Loc]** **[Doc]** ``` </details>
2 parents 09fb1b4 + c40e3a6 commit daf1a46

31 files changed

+334
-129
lines changed

CollapseLauncher/Classes/Extension/DictionaryExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44

5-
namespace CollapseLauncher.Classes.Extension
5+
namespace CollapseLauncher.Extension
66
{
77
#nullable enable
88
public static class DictionaryExtension
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.UI.Dispatching;
2+
using System;
3+
4+
namespace CollapseLauncher.Extension
5+
{
6+
public static class DispatcherQueueExtensions
7+
{
8+
public static bool HasThreadAccessSafe(this DispatcherQueue queue)
9+
{
10+
if (queue == null) return false;
11+
12+
try
13+
{
14+
return queue.HasThreadAccess;
15+
}
16+
catch (ObjectDisposedException)
17+
{
18+
return false; // Return false if an exception occurs
19+
}
20+
}
21+
}
22+
}

CollapseLauncher/Classes/Extension/UIElementExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ internal static void ApplyDropShadow(this FrameworkElement element, Color? shado
905905
// attach the shadow while the element is already loaded.
906906
if (element.Parent is null) element.Loaded += (_, _) =>
907907
{
908-
if (element.DispatcherQueue.HasThreadAccess)
908+
if (element.DispatcherQueue.HasThreadAccessSafe())
909909
AssignShadowAttachment(element, isMasked);
910910
else
911911
element.DispatcherQueue.TryEnqueue(() => AssignShadowAttachment(element, isMasked));

CollapseLauncher/Classes/Extension/VelopackLocatorExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// ReSharper disable CommentTypo
2121

2222
#nullable enable
23-
namespace CollapseLauncher.Classes.Extension
23+
namespace CollapseLauncher.Extension
2424
{
2525
internal static class VelopackLocatorExtension
2626
{

CollapseLauncher/Classes/Extension/VelopackLoggerExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System;
33
using Velopack.Logging;
44

5-
namespace CollapseLauncher.Classes.Extension
5+
namespace CollapseLauncher.Extension
66
{
77
public class VelopackLoggerAdaptor(ILogger logger) : IVelopackLogger
88
{

CollapseLauncher/Classes/Helper/Animation/AnimationHelper.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using CollapseLauncher.Extension;
12
using Hi3Helper;
23
using Hi3Helper.CommunityToolkit.WinUI.Controls;
34
using Hi3Helper.SentryHelper;
@@ -35,7 +36,7 @@ internal static async void StartAnimationDetached(this UIElement element, TimeSp
3536
{
3637
foreach (KeyFrameAnimation anim in animBase!)
3738
{
38-
if (element?.DispatcherQueue?.HasThreadAccess ?? false)
39+
if (element?.DispatcherQueue?.HasThreadAccessSafe() ?? false)
3940
{
4041
anim!.Duration = duration;
4142
element.StartAnimation(anim);
@@ -53,7 +54,7 @@ internal static async void StartAnimationDetached(this UIElement element, TimeSp
5354
internal static async Task StartAnimation(this UIElement element, TimeSpan duration, params KeyFrameAnimation[] animBase)
5455
{
5556
CompositionAnimationGroup animGroup = null;
56-
if (element.DispatcherQueue?.HasThreadAccess ?? false)
57+
if (element.DispatcherQueue?.HasThreadAccessSafe() ?? false)
5758
{
5859
animGroup = CompositionTarget.GetCompositorForCurrentThread().CreateAnimationGroup();
5960
}
@@ -69,7 +70,7 @@ internal static async Task StartAnimation(this UIElement element, TimeSpan durat
6970
{
7071
foreach (KeyFrameAnimation anim in animBase!)
7172
{
72-
if (element.DispatcherQueue?.HasThreadAccess ?? false)
73+
if (element.DispatcherQueue?.HasThreadAccessSafe() ?? false)
7374
{
7475
anim.Duration = duration;
7576
anim.StopBehavior = AnimationStopBehavior.LeaveCurrentValue;
@@ -83,7 +84,7 @@ internal static async Task StartAnimation(this UIElement element, TimeSpan durat
8384
animGroup.Add(anim);
8485
});
8586
}
86-
if (element.DispatcherQueue?.HasThreadAccess ?? false)
87+
if (element.DispatcherQueue?.HasThreadAccessSafe() ?? false)
8788
{
8889
element.StartAnimation(animGroup);
8990
}

CollapseLauncher/Classes/Helper/Background/BackgroundMediaUtility.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ internal void Pause()
489489

490490
public static void SetAlternativeFileStream(FileStream stream)
491491
{
492+
_alternativeFileStream?.Dispose();
492493
_alternativeFileStream = stream;
493494
}
494495

CollapseLauncher/Classes/Helper/Database/DBHandler.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,17 @@ public static async Task Init(bool redirectThrow = false, bool bypassEnableFlag
137137
_ = UserId;
138138

139139
if (string.IsNullOrEmpty(Uri))
140-
throw new NullReferenceException(Lang._SettingsPage.Database_Error_EmptyUri);
140+
{
141+
IsEnabled = false;
142+
throw new NullReferenceException($"DB_001 {Lang._SettingsPage.Database_Error_EmptyUri}");
143+
}
144+
141145
if (string.IsNullOrEmpty(Token))
142-
throw new NullReferenceException(Lang._SettingsPage.Database_Error_EmptyToken);
146+
{
147+
IsEnabled = false;
148+
throw new NullReferenceException($"DB_002 {Lang._SettingsPage.Database_Error_EmptyToken}");
149+
}
150+
143151

144152
// Connect to database
145153
// Libsql-client-dotnet technically support file based SQLite by pushing `file://` proto in the URL.
@@ -184,7 +192,7 @@ public static async Task Init(bool redirectThrow = false, bool bypassEnableFlag
184192
{
185193
LogWriteLine($"[DBHandler::Init] Error when connecting to database system! Token invalid!\r\n{e}",
186194
LogType.Error, true);
187-
var ex = new AggregateException("Unauthorized: wrong token inserted", e);
195+
var ex = new AggregateException("DB_003 Unauthorized: wrong token inserted", e);
188196
throw ex;
189197
}
190198
catch (Exception e)

CollapseLauncher/Classes/Helper/Loading/LoadingMessageHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal static async void ShowLoadingFrame()
7878
{
7979
try
8080
{
81-
if (CurrentMainWindow.LoadingStatusBackgroundGrid.DispatcherQueue.HasThreadAccess)
81+
if (CurrentMainWindow.LoadingStatusBackgroundGrid.DispatcherQueue.HasThreadAccessSafe())
8282
{
8383
await ShowLoadingFrameInner();
8484
return;
@@ -118,7 +118,7 @@ internal static async void HideLoadingFrame()
118118
{
119119
try
120120
{
121-
if (CurrentMainWindow.LoadingStatusBackgroundGrid.DispatcherQueue.HasThreadAccess)
121+
if (CurrentMainWindow.LoadingStatusBackgroundGrid.DispatcherQueue.HasThreadAccessSafe())
122122
{
123123
await HideLoadingFrameInner();
124124
return;

CollapseLauncher/Classes/Helper/TaskSchedulerHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CollapseLauncher.Classes.Extension;
1+
using CollapseLauncher.Extension;
22
using Hi3Helper;
33
using Hi3Helper.SentryHelper;
44
using Hi3Helper.Shared.Region;

0 commit comments

Comments
 (0)