[PTRun]Fix crash when plugins have the same name (#15456)

This commit is contained in:
Jaime Bernardo
2022-01-11 23:12:00 +00:00
committed by GitHub
parent d52037fd5e
commit 1a9473c896
2 changed files with 23 additions and 8 deletions

View File

@@ -9,6 +9,10 @@ namespace PowerLauncher.Telemetry.Events
[EventData]
public class PluginModel
{
public string ID { get; set; }
public string Name { get; set; }
public bool Disabled { get; set; }
public bool IsGlobal { get; set; }

View File

@@ -52,9 +52,13 @@ namespace PowerLauncher
private void SendSettingsTelemetry()
{
Log.Info("Send Run settings telemetry", this.GetType());
var plugins = PluginManager.AllPlugins.ToDictionary(x => x.Metadata.Name, x => new PluginModel()
try
{
Log.Info("Send Run settings telemetry", this.GetType());
var plugins = PluginManager.AllPlugins.ToDictionary(x => x.Metadata.Name + " " + x.Metadata.ID, x => new PluginModel()
{
ID = x.Metadata.ID,
Name = x.Metadata.Name,
Disabled = x.Metadata.Disabled,
ActionKeyword = x.Metadata.ActionKeyword,
IsGlobal = x.Metadata.IsGlobal,
@@ -63,6 +67,13 @@ namespace PowerLauncher
var telemetryEvent = new RunPluginsSettingsEvent(plugins);
PowerToysTelemetry.Log.WriteEvent(telemetryEvent);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
Log.Exception("Unhandled exception when trying to send PowerToys Run settings telemetry.", ex, GetType());
}
}
protected override void OnSourceInitialized(EventArgs e)
{