Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI][Bug] Exception thrown in MainViewModel.PopulateLayout #49

Closed
jcoliz opened this issue Sep 16, 2024 · 5 comments
Closed

[UI][Bug] Exception thrown in MainViewModel.PopulateLayout #49

jcoliz opened this issue Sep 16, 2024 · 5 comments
Labels
bug Something isn't working P1-Must Have

Comments

@jcoliz
Copy link
Owner

jcoliz commented Sep 16, 2024

Repro steps

  1. Loaded LogoSlideMaker.WinUi\Sample\sample-packed.toml into previewer
  2. Loaded sample\sample.toml into previewer
  3. Displays error "Opening file failed": "Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')"

Root cause investigation

This code looks suspect! Is not considering whether _slideNumber is in range at all. That said, I don't really understand why _slideNumber is NOT in range because incoming definition does have a variant.

var variant = _definition.Variants.Count > 0 ? _definition.Variants[_slideNumber] : new Variant();

Hmm, this may be a timing problem. In this case the OLD file, sample-packed does not have a variant. So for this moment, are we getting the count of variants from the OLD file, and then trying to read the variant out of the NEW file?? No, that's backwards. Will need to investigate further.

Logs

2024-09-16 12:53:32.762 -07:00 [INF] OpenDocument: Selected OK C:\Source\jcoliz\LogoSlideMaker\sample\sample.toml
2024-09-16 12:53:32.766 -07:00 [ERR] LoadDefinitionAsync: Stream load Failed
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at LogoSlideMaker.WinUi.ViewModels.MainViewModel.PopulateLayout()
   at LogoSlideMaker.WinUi.ViewModels.MainViewModel.<>c__DisplayClass68_0.<LoadDefinitionAsync>b__0()
2024-09-16 12:53:32.799 -07:00 [DBG] LoadDefinitionAsync: Launched
2024-09-16 12:53:36.161 -07:00 [INF] ShowErrorAsync: OK Opening file failed Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

Found in version

ci-3420 9d78c00

@jcoliz
Copy link
Owner Author

jcoliz commented Sep 16, 2024

It seems I cannot load ANY file, after having loaded sample-packed.toml!

@jcoliz jcoliz added bug Something isn't working P1-Must Have labels Sep 16, 2024
@jcoliz
Copy link
Owner Author

jcoliz commented Sep 16, 2024

Does not repro in the debugger. So almost certainly a timing problem.

@jcoliz
Copy link
Owner Author

jcoliz commented Sep 16, 2024

Also doesn't repro using locally-built copy in Debug

@jcoliz
Copy link
Owner Author

jcoliz commented Sep 16, 2024

Also doesn't repro using locally-built copy in Release (!?)

@jcoliz
Copy link
Owner Author

jcoliz commented Sep 16, 2024

Also doesn't repro again after re-install of same bits. Will add some extra logging and close.

@jcoliz jcoliz closed this as completed in d5137b9 Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1-Must Have
Projects
None yet
Development

No branches or pull requests

1 participant