TestStack / White

DEPRECATED - no longer actively maintained
Other
1.02k stars 485 forks source link

Window.TitleBar can be null in Window.set_DisplayState #641

Open DeltaIII opened 5 years ago

DeltaIII commented 5 years ago

The getter for Window.TitleBar (Window.cs:397-400) returns a new instance each time it is called: public virtual TitleBar TitleBar { get { return factory.GetTitleBar(this); } }

This means that the following code in Window.set_DisplayState (Window.cs:336-338): if (AlreadyInAskedState(value) || TitleBar == null) return; TitleBar.SetDisplayState(value); uses two different instances of TitleBar, including a possible null reference (from PrimaryUIItemFactory.GetTitleBar).

Because Window.get_TitleBar returns a new instance on each call, both references to Window.TitleBar in Window.set_DisplayState should use the same local variable. It may also be worth hiding the property TitleBar behind a method that declares the return of each call as a new, possibly null, object.