mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-11 05:52:19 +02:00
[PTRun] Fix crash when shutting Windows down (#13401)
This commit is contained in:
@@ -40,6 +40,9 @@ namespace PowerLauncher
|
|||||||
private StringMatcher _stringMatcher;
|
private StringMatcher _stringMatcher;
|
||||||
private SettingsReader _settingsReader;
|
private SettingsReader _settingsReader;
|
||||||
|
|
||||||
|
// To prevent two disposals running at the same time.
|
||||||
|
private static readonly object _disposingLock = new object();
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
@@ -238,8 +241,22 @@ namespace PowerLauncher
|
|||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!_disposed)
|
// Prevent two disposes at the same time.
|
||||||
|
lock (_disposingLock)
|
||||||
{
|
{
|
||||||
|
if (!disposing)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_disposed = true;
|
||||||
|
}
|
||||||
|
|
||||||
Stopwatch.Normal("App.OnExit - Exit cost", () =>
|
Stopwatch.Normal("App.OnExit - Exit cost", () =>
|
||||||
{
|
{
|
||||||
Log.Info("Start PowerToys Run Exit---------------------------------------------------- ", GetType());
|
Log.Info("Start PowerToys Run Exit---------------------------------------------------- ", GetType());
|
||||||
@@ -256,16 +273,13 @@ namespace PowerLauncher
|
|||||||
API?.Dispose();
|
API?.Dispose();
|
||||||
_mainVM?.Dispose();
|
_mainVM?.Dispose();
|
||||||
_themeManager?.Dispose();
|
_themeManager?.Dispose();
|
||||||
_disposed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
|
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
|
||||||
// TODO: set large fields to null
|
// TODO: set large fields to null
|
||||||
_disposed = true;
|
|
||||||
Log.Info("End PowerToys Run Exit ---------------------------------------------------- ", GetType());
|
Log.Info("End PowerToys Run Exit ---------------------------------------------------- ", GetType());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
|
// // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
|
||||||
// ~App()
|
// ~App()
|
||||||
|
|||||||
Reference in New Issue
Block a user