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

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

Open
DeltaIII opened this issue Mar 26, 2019 · 0 comments
Open

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

DeltaIII opened this issue Mar 26, 2019 · 0 comments

Comments

@DeltaIII
Copy link

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.

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

No branches or pull requests

1 participant