mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[Run-Plugin][Program] Fix null reference exception on Dispose (#11785)
This commit is contained in:
@@ -170,8 +170,12 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
|
|||||||
if (!_disposed)
|
if (!_disposed)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
{
|
||||||
|
if (_context != null && _context.API != null)
|
||||||
{
|
{
|
||||||
_context.API.ThemeChanged -= OnThemeChanged;
|
_context.API.ThemeChanged -= OnThemeChanged;
|
||||||
|
}
|
||||||
|
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,8 +133,12 @@ namespace Microsoft.Plugin.Folder
|
|||||||
if (!_disposed)
|
if (!_disposed)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
{
|
||||||
|
if (_context != null && _context.API != null)
|
||||||
{
|
{
|
||||||
_context.API.ThemeChanged -= OnThemeChanged;
|
_context.API.ThemeChanged -= OnThemeChanged;
|
||||||
|
}
|
||||||
|
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,9 +209,13 @@ namespace Microsoft.Plugin.Program
|
|||||||
if (!_disposed)
|
if (!_disposed)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
{
|
||||||
|
if (_context != null && _context.API != null)
|
||||||
{
|
{
|
||||||
_context.API.ThemeChanged -= OnThemeChanged;
|
_context.API.ThemeChanged -= OnThemeChanged;
|
||||||
_win32ProgramRepositoryHelper.Dispose();
|
}
|
||||||
|
|
||||||
|
_win32ProgramRepositoryHelper?.Dispose();
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,8 +225,12 @@ namespace Microsoft.Plugin.Uri
|
|||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!_disposed && disposing)
|
if (!_disposed && disposing)
|
||||||
|
{
|
||||||
|
if (Context != null && Context.API != null)
|
||||||
{
|
{
|
||||||
Context.API.ThemeChanged -= OnThemeChanged;
|
Context.API.ThemeChanged -= OnThemeChanged;
|
||||||
|
}
|
||||||
|
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,8 +112,12 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
|||||||
if (!_disposed)
|
if (!_disposed)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
{
|
||||||
|
if (Context != null && Context.API != null)
|
||||||
{
|
{
|
||||||
Context.API.ThemeChanged -= OnThemeChanged;
|
Context.API.ThemeChanged -= OnThemeChanged;
|
||||||
|
}
|
||||||
|
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Registry
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(_context is null))
|
if (_context != null && _context.API != null)
|
||||||
{
|
{
|
||||||
_context.API.ThemeChanged -= OnThemeChanged;
|
_context.API.ThemeChanged -= OnThemeChanged;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ namespace Microsoft.PowerToys.Run.Plugin.WindowsSettings
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(_context is null))
|
if (_context != null && _context.API != null)
|
||||||
{
|
{
|
||||||
_context.API.ThemeChanged -= OnThemeChanged;
|
_context.API.ThemeChanged -= OnThemeChanged;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user