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

fix: null reference exception when Container.Parent is null #511

Closed
wants to merge 1 commit into from

Conversation

maxle5
Copy link
Contributor

@maxle5 maxle5 commented Jan 16, 2024

Exception:

01/16/2024 7:13:59 AM
System.NullReferenceException: Object reference not set to an instance of an object.
   at GlazeWM.Domain.Containers.Container.get_Siblings() in E:\GlazeWM\GlazeWM.Domain\Containers\Container.cs:line 46
   at GlazeWM.Domain.Containers.CommandHandlers.DetachContainerHandler.Handle(DetachContainerCommand command) in E:\GlazeWM\GlazeWM.Domain\Containers\CommandHandlers\DetachContainerHandler.cs:line 32
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in E:\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 48
   at GlazeWM.Domain.Monitors.CommandHandlers.RemoveMonitorHandler.Handle(RemoveMonitorCommand command) in E:\GlazeWM\GlazeWM.Domain\Monitors\CommandHandlers\RemoveMonitorHandler.cs:line 47
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in E:\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 48
   at GlazeWM.Domain.Monitors.CommandHandlers.RefreshMonitorStateHandler.Handle(RefreshMonitorStateCommand command) in E:\GlazeWM\GlazeWM.Domain\Monitors\CommandHandlers\RefreshMonitorStateHandler.cs:line 63
   at GlazeWM.Infrastructure.Bussing.Bus.Invoke[T](T command) in E:\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 48
   at GlazeWM.Domain.Monitors.EventHandlers.DisplaySettingsChangedHandler.Handle(DisplaySettingsChangedEvent event) in E:\GlazeWM\GlazeWM.Domain\Monitors\EventHandlers\DisplaySettingsChangedHandler.cs:line 18
   at GlazeWM.Infrastructure.Bussing.Bus.Emit[T](T event) in E:\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 87
   at GlazeWM.Infrastructure.Bussing.Bus.<>c__DisplayClass8_0`1.<EmitAsync>b__0() in E:\GlazeWM\GlazeWM.Infrastructure\Bussing\Bus.cs:line 101

Background:

  • This occurs every time I wake my computer from sleep after having it previously connected to a monitor (e.g. laptop plugged into a monitor at work but not connected to a monitor when I get home).
  • Seems to be caused by a recently added method Container.RemoveChild where the Parent property is set to null.

Only thing I'm not 100% sure about is whether or not I should have set the "fallbacks" for Index properties to -1 or to 0? I was worried setting to -1 would cause an index out of range exceptions somewhere...

@maxle5 maxle5 marked this pull request as ready for review January 16, 2024 11:51
@maxle5
Copy link
Contributor Author

maxle5 commented Jan 19, 2024

noticing some other issues due to this solution, closing until I can come back to this

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 this pull request may close these issues.

1 participant