File tree 3 files changed +27
-2
lines changed
StabilityMatrix.Avalonia/ViewModels/Settings
StabilityMatrix.Core/Helper/HardwareInfo
3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
8
8
## v2.7.3
9
9
### Fixed
10
10
- Fixed UnicodeDecodeError when using extra_model_paths.yaml in ComfyUI on certain locales
11
+ - Fixed [ #334 ] ( https://github.com/LykosAI/StabilityMatrix/issues/334 ) - Win32Exception if Settings are opened
11
12
12
13
## v2.7.2
13
14
### Changed
Original file line number Diff line number Diff line change @@ -212,7 +212,6 @@ public override void OnLoaded()
212
212
base . OnLoaded ( ) ;
213
213
214
214
hardwareInfoUpdateTimer . Start ( ) ;
215
- OnHardwareInfoUpdateTimerTick ( null , null ! ) ;
216
215
}
217
216
218
217
/// <inheritdoc />
@@ -236,7 +235,10 @@ public override async Task OnLoadedAsync()
236
235
237
236
private void OnHardwareInfoUpdateTimerTick ( object ? sender , EventArgs e )
238
237
{
239
- MemoryInfo = HardwareHelper . GetMemoryInfo ( ) ;
238
+ if ( HardwareHelper . IsMemoryInfoAvailable && HardwareHelper . TryGetMemoryInfo ( out var newMemoryInfo ) )
239
+ {
240
+ MemoryInfo = newMemoryInfo ;
241
+ }
240
242
}
241
243
242
244
partial void OnSelectedThemeChanged ( string ? value )
Original file line number Diff line number Diff line change 5
5
using System . Text . RegularExpressions ;
6
6
using Hardware . Info ;
7
7
using Microsoft . Win32 ;
8
+ using NLog ;
8
9
9
10
namespace StabilityMatrix . Core . Helper . HardwareInfo ;
10
11
11
12
public static partial class HardwareHelper
12
13
{
14
+ private static readonly Logger Logger = LogManager . GetCurrentClassLogger ( ) ;
15
+
13
16
private static IReadOnlyList < GpuInfo > ? cachedGpuInfos ;
14
17
15
18
private static readonly Lazy < IHardwareInfo > HardwareInfoLazy = new ( ( ) => new Hardware . Info . HardwareInfo ( ) ) ;
@@ -149,6 +152,25 @@ public static bool HasAmdGpu()
149
152
// Set DirectML for default if AMD and Windows
150
153
public static bool PreferDirectML ( ) => ! HasNvidiaGpu ( ) && HasAmdGpu ( ) && Compat . IsWindows ;
151
154
155
+ private static readonly Lazy < bool > IsMemoryInfoAvailableLazy = new ( ( ) => TryGetMemoryInfo ( out _ ) ) ;
156
+ public static bool IsMemoryInfoAvailable => IsMemoryInfoAvailableLazy . Value ;
157
+
158
+ public static bool TryGetMemoryInfo ( out MemoryInfo memoryInfo )
159
+ {
160
+ try
161
+ {
162
+ memoryInfo = GetMemoryInfo ( ) ;
163
+ return true ;
164
+ }
165
+ catch ( Exception ex )
166
+ {
167
+ Logger . Warn ( ex , "Failed to get memory info" ) ;
168
+
169
+ memoryInfo = default ;
170
+ return false ;
171
+ }
172
+ }
173
+
152
174
/// <summary>
153
175
/// Gets the total and available physical memory in bytes.
154
176
/// </summary>
You can’t perform that action at this time.
0 commit comments