Also fix event handler accumulation in OptionsWindow

- Add _isInitialized flag to OptionsWindow to prevent multiple ThemeChanged subscriptions
- Ensures ThemeChanged event is only subscribed once

Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-16 20:14:34 +00:00
parent 6f52b82a6d
commit 8dee5c0d3c

View File

@@ -12,6 +12,7 @@ namespace mRemoteNG.UI.Window
public partial class OptionsWindow : BaseWindow
{
private FrmOptions _optionsForm;
private bool _isInitialized = false;
#region Public Methods
@@ -34,8 +35,14 @@ namespace mRemoteNG.UI.Window
private void Options_Load(object sender, EventArgs e)
{
// Only subscribe to ThemeChanged once to prevent multiple subscriptions
if (!_isInitialized)
{
ThemeManager.getInstance().ThemeChanged += ApplyTheme;
_isInitialized = true;
}
ApplyTheme();
ThemeManager.getInstance().ThemeChanged += ApplyTheme;
ApplyLanguage();
LoadOptionsForm();
}