mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
CmdPal: Add null check before caching view model for item (#45815)
This commit is contained in:
@@ -227,6 +227,13 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
||||
var reused = 0;
|
||||
foreach (var item in newItems)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (item is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for cancellation during item processing
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
@@ -255,6 +262,11 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
||||
created++;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CoreLogger.LogError("Failed to load item:\n", ex + ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
CoreLogger.LogInfo($"[ListViewModel] FetchItems: {created} created, {reused} reused, {_vmCache.Count} cached");
|
||||
|
||||
Reference in New Issue
Block a user