Skip to content

Commit 05c9268

Browse files
authored
Fix: Fixed NullReferenceException in SystemTrayIcon.OnQuitClicked (#15923)
1 parent f370b86 commit 05c9268

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Files.App/Utils/Taskbar/SystemTrayIcon.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ private void OnRestartClicked()
279279
{
280280
Microsoft.Windows.AppLifecycle.AppInstance.Restart("");
281281

282-
Program.Pool.Release();
282+
var pool = new Semaphore(0, 1, $"Files-{AppLifecycleHelper.AppEnvironment}-Instance", out var isNew);
283+
if (!isNew)
284+
pool.Release();
285+
283286
Environment.Exit(0);
284287
}
285288

@@ -288,8 +291,10 @@ private void OnQuitClicked()
288291
Hide();
289292

290293
App.AppModel.ForceProcessTermination = true;
291-
if (Program.Pool is not null)
292-
Program.Pool.Release();
294+
295+
var pool = new Semaphore(0, 1, $"Files-{AppLifecycleHelper.AppEnvironment}-Instance", out var isNew);
296+
if (!isNew)
297+
pool.Release();
293298
else
294299
App.Current.Exit();
295300
}

0 commit comments

Comments
 (0)