mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
[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.
This commit is contained in:
@@ -486,6 +486,11 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
|||||||
{
|
{
|
||||||
if (!item.SafeSlowInit())
|
if (!item.SafeSlowInit())
|
||||||
{
|
{
|
||||||
|
// Even if initialization fails, we need to hide any previously shown details
|
||||||
|
DoOnUiThread(() =>
|
||||||
|
{
|
||||||
|
WeakReferenceMessenger.Default.Send<HideDetailsMessage>();
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,9 @@ public partial class InstallPackageListItem : ListItem
|
|||||||
// These can be l o n g
|
// These can be l o n g
|
||||||
{ Properties.Resources.winget_release_notes, (metadata.ReleaseNotes, string.Empty) },
|
{ Properties.Resources.winget_release_notes, (metadata.ReleaseNotes, string.Empty) },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
var docs = metadata.Documentations;
|
var docs = metadata.Documentations;
|
||||||
var count = docs.Count;
|
var count = docs.Count;
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
@@ -139,6 +142,11 @@ public partial class InstallPackageListItem : ListItem
|
|||||||
var item = docs[i];
|
var item = docs[i];
|
||||||
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
|
simpleData.Add(item.DocumentLabel, (string.Empty, item.DocumentUrl));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Failed to retrieve documentations from metadata: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
UriCreationOptions options = default;
|
UriCreationOptions options = default;
|
||||||
foreach (var kv in simpleData)
|
foreach (var kv in simpleData)
|
||||||
@@ -159,6 +167,8 @@ public partial class InstallPackageListItem : ListItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (metadata.Tags.Count > 0)
|
if (metadata.Tags.Count > 0)
|
||||||
{
|
{
|
||||||
DetailsElement pair = new()
|
DetailsElement pair = new()
|
||||||
@@ -168,6 +178,11 @@ public partial class InstallPackageListItem : ListItem
|
|||||||
};
|
};
|
||||||
detailsElements.Add(pair);
|
detailsElements.Add(pair);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogWarning($"Failed to retrieve tags from metadata: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
return detailsElements;
|
return detailsElements;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user