mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-04 19:59:35 +00:00
Compare commits
2 Commits
copilot/fi
...
copilot/fi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4742908983 | ||
![]() |
ccbe1c297a |
@@ -220,6 +220,9 @@ public partial class App : Application
|
||||
ThemeManager.Apply(OSThemeHelper.AppsUseDarkTheme() ? ApplicationTheme.Dark : ApplicationTheme.Light);
|
||||
UxTheme.ApplyPreferredAppMode();
|
||||
|
||||
// Handle power management events to prevent crashes after sleep/wake
|
||||
SystemEvents.PowerModeChanged += OnPowerModeChanged;
|
||||
|
||||
// Initialize TrayIcon
|
||||
_ = TrayIconManager.GetInstance();
|
||||
|
||||
@@ -303,6 +306,9 @@ public partial class App : Application
|
||||
if (!_cleanExit)
|
||||
return;
|
||||
|
||||
// Unsubscribe from power management events
|
||||
SystemEvents.PowerModeChanged -= OnPowerModeChanged;
|
||||
|
||||
_isRunning.ReleaseMutex();
|
||||
|
||||
PipeServerManager.GetInstance().Dispose();
|
||||
@@ -330,4 +336,28 @@ public partial class App : Application
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (e.Mode)
|
||||
{
|
||||
case PowerModes.Suspend:
|
||||
// System is going to sleep - close any open preview windows to prevent graphics issues
|
||||
ProcessHelper.WriteLog("System entering sleep mode - closing preview windows");
|
||||
ViewWindowManager.GetInstance().ClosePreview();
|
||||
break;
|
||||
case PowerModes.Resume:
|
||||
// System waking up - log for debugging
|
||||
ProcessHelper.WriteLog("System resumed from sleep mode");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Don't let power management exceptions crash the app
|
||||
ProcessHelper.WriteLog($"Error handling power mode change: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user