Compare commits

...

4 Commits

Author SHA1 Message Date
Shawn Yuan (from Dev Box)
7b945139ec update 2026-01-21 10:02:18 +08:00
Shawn Yuan (from Dev Box)
549e4c1a62 code clean 2026-01-21 10:00:32 +08:00
Shawn Yuan (from Dev Box)
c1af6b8030 init 2026-01-21 09:58:03 +08:00
Michael Jolley
b5e9f346da [CmdPal] Fix details pane not hiding when item initialization fails (#44757)
Fixes #44487

## Summary
Fixed issue where the details pane would display stale information when
navigating from an item with details to an item without details or where
details failed to load.

## Changes
1. **ListViewModel.cs**: Added HideDetailsMessage when SafeSlowInit()
fails to ensure previous details are cleared
2. **InstallPackageListItem.cs**: Added exception handling for WinRT
marshaling errors when accessing metadata.Documentations and
metadata.Tags collections

The fix ensures graceful degradation - if certain metadata collections
fail to load due to WinRT issues, the details pane still displays
available information rather than failing completely.
2026-01-20 19:16:43 -06:00
3 changed files with 38 additions and 15 deletions

View File

@@ -486,6 +486,11 @@ public partial class ListViewModel : PageViewModel, IDisposable
{
if (!item.SafeSlowInit())
{
// Even if initialization fails, we need to hide any previously shown details
DoOnUiThread(() =>
{
WeakReferenceMessenger.Default.Send<HideDetailsMessage>();
});
return;
}

View File

@@ -132,12 +132,20 @@ public partial class InstallPackageListItem : ListItem
// These can be l o n g
{ Properties.Resources.winget_release_notes, (metadata.ReleaseNotes, string.Empty) },
};
var docs = metadata.Documentations;
var count = docs.Count;
for (var i = 0; i < count; i++)
try
{
var item = docs[i];
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
var docs = metadata.Documentations;
var count = docs.Count;
for (var i = 0; i < count; i++)
{
var item = docs[i];
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
}
}
catch (Exception ex)
{
Logger.LogWarning($"Failed to retrieve documentations from metadata: {ex.Message}");
}
UriCreationOptions options = default;
@@ -159,14 +167,21 @@ public partial class InstallPackageListItem : ListItem
}
}
if (metadata.Tags.Count > 0)
try
{
DetailsElement pair = new()
if (metadata.Tags.Count > 0)
{
Key = "Tags",
Data = new DetailsTags() { Tags = metadata.Tags.Select(t => new Tag(t)).ToArray() },
};
detailsElements.Add(pair);
DetailsElement pair = new()
{
Key = "Tags",
Data = new DetailsTags() { Tags = metadata.Tags.Select(t => new Tag(t)).ToArray() },
};
detailsElements.Add(pair);
}
}
catch (Exception ex)
{
Logger.LogWarning($"Failed to retrieve tags from metadata: {ex.Message}");
}
return detailsElements;

View File

@@ -76,16 +76,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
GeneralSettingsConfig = settingsRepository.SettingsConfig;
// To obtain the settings configurations of Fancy zones.
ArgumentNullException.ThrowIfNull(settingsRepository);
// To obtain the settings configurations of Advanced Paste.
ArgumentNullException.ThrowIfNull(advancedPasteSettingsRepository);
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();
_settingsUtils = settingsUtils ?? throw new ArgumentNullException(nameof(settingsUtils));
ArgumentNullException.ThrowIfNull(advancedPasteSettingsRepository);
_advancedPasteSettings = advancedPasteSettingsRepository.SettingsConfig ?? throw new ArgumentException("SettingsConfig cannot be null", nameof(advancedPasteSettingsRepository));
_advancedPasteSettings = advancedPasteSettingsRepository.SettingsConfig;
if (_advancedPasteSettings.Properties is null)
{
throw new ArgumentException("AdvancedPasteSettings.Properties cannot be null", nameof(advancedPasteSettingsRepository));
}
AttachConfigurationHandlers();