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

[BUG] StackOverflowException when using OnThemeChanged to update the UI #32

Closed
wolframhaussig opened this issue Feb 25, 2024 · 0 comments · Fixed by #33
Closed

[BUG] StackOverflowException when using OnThemeChanged to update the UI #32

wolframhaussig opened this issue Feb 25, 2024 · 0 comments · Fixed by #33
Assignees

Comments

@wolframhaussig
Copy link
Contributor

wolframhaussig commented Feb 25, 2024

Describe the bug
when using ThemeRegistry.OnThemeChanged to update the UI, a StackOverflowException is thrown. The reason: ThemeRegistry currently calls the event handlers BEFORE the new theme is set. When the event handler tries to access the current Theme, the check is done again and as the current theme has not been updated yet, the events are triggered again.

Solution: Call handlers AFTER the new theme is set.

To Reproduce

private void ThemeRegistry_OnThemeChanged(object sender, EventArgs e)
{
     ThemeRegistryHolder.ThemeRegistry.CurrentTheme.Apply(this);
}

Expected behavior
No exception should be thrown

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

Successfully merging a pull request may close this issue.

1 participant