Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Sledge stuck in infinite loop when multiple tabs are open #311

Open
SamVanheer opened this issue Jul 18, 2019 · 1 comment
Open

Sledge stuck in infinite loop when multiple tabs are open #311

SamVanheer opened this issue Jul 18, 2019 · 1 comment

Comments

@SamVanheer
Copy link

When multiple tabs are open Sledge will get stuck in an infinite loop because it continually raises Document:Activated events in response to tab change events. An event handler for Document:Activated sets the tab index which raises the tab change event.

The documentation for SelectedIndex and SelectedIndexChanged say nothing about raising events if the value is the same, and the source code for the Core port (https://github.com/dotnet/winforms/blob/bced3b69dfb164230f300877a595afc9a000d1a6/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs) indicates that it shouldn't, but it is calling into native code for a portion of the logic.

I suggest adding a sanity check to the event handler to ignore tab change events if the index hasn't actually changed to stop the infinite loop.
Alternatively, don't change the tab index if the value is identical (this should match what WinForms is doing internally though).

Note that this only appears to be happening when Sledge is opened with multiple tabs to restore. It didn't happen when i initially opened the maps.

@SamVanheer
Copy link
Author

It's possible that what i experienced was actually caused by the Oy event system delaying the response so this happens:

  1. First map is loaded and made current, event is pushed
  2. Second map is loaded and made current, event is pushed
  3. Third map is loaded and made current, event is pushed
  4. First event is handled and makes first map current, event is pushed
  5. Second event is handled and makes second map current, event is pushed
  6. Third event is handled and makes third map current, event is pushed
  7. Goto 4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant