mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
This commit resolves multiple related issues with the Options dialog that caused freezing, crashes, and slow performance: **Problem 1: Infinite Recursive Loop** - Symptom: Options dialog would freeze when navigating between pages - Cause: LstOptionPages_SelectedIndexChanged event handler triggering itself infinitely - Fix: Added _isHandlingSelectionChange guard flag to prevent recursive calls **Problem 2: Disposed Object Exception** - Symptom: "Cannot access a disposed object" error after SSH connection workflow - Cause: Static FrmOptions instance was disposed but still referenced - Fix: Enhanced OptionsWindow.LoadOptionsForm() to detect disposal before use - Fix: Added FrmMain.RecreateOptionsForm() to recreate disposed forms transparently **Problem 3: Index Out of Range** - Symptom: "index must be less than 0" when accessing empty lstOptionPages - Cause: SetActivatedPage() tried to access Items[0] when collection was empty - Fix: Added bounds checking before accessing lstOptionPages.Items **Problem 4: NullReferenceException in OptionsPages** - Symptom: NullReferenceException in LoadRegistrySettings() across all pages - Cause: pageRegSettingsInstance was null when registry settings didn't exist - Fix: Added null checks and default instance creation in 8 OptionsPages **Problem 5: Slow Page Loading on Recreation** - Symptom: Second Options dialog open showed staggered page loading (~2.2 seconds) - Cause: Application.Idle async pattern loaded pages one-by-one - Fix: Replaced async loading with synchronous batch loading using BeginUpdate/EndUpdate **Files Modified:** - mRemoteNG/UI/Forms/frmOptions.cs - mRemoteNG/UI/Window/OptionsWindow.cs - mRemoteNG/UI/Forms/frmMain.cs - mRemoteNG/UI/Forms/OptionsPages/StartupExitPage.cs - mRemoteNG/UI/Forms/OptionsPages/NotificationsPage.cs - mRemoteNG/UI/Forms/OptionsPages/AppearancePage.cs - mRemoteNG/UI/Forms/OptionsPages/SecurityPage.cs - mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.cs - mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.cs - mRemoteNG/UI/Forms/OptionsPages/TabsPanelsPage.cs - mRemoteNG/UI/Forms/OptionsPages/UpdatesPage.cs **Additional Changes:** - Replaced all Debug.WriteLine with Logger.Instance.Log for consistent logging - Added comprehensive debug logging throughout Options form lifecycle - Improved defensive programming with guard flags and validation checks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>