Skip to content

NullReferenceException when accessing ColorScheme in View.cs #1993

@heinrich-ulbricht

Description

@heinrich-ulbricht

Describe the bug

Got a NullReferenceException in View.cs when working with message boxes.

To Reproduce

This is a currently a sporadic error and probably a timing issue. Cannot reliably reproduce. I nevertheless want to document this in case it becomes relevant/reproducible or anybody immediately sees what's up.

Expected behavior
I expect such an error not to happen.

Screenshots
Here's the debugger halting (View.cs):

image

And here the call stack:

>	Terminal.Gui.dll!Terminal.Gui.View.GetNormalColor() Line 3003	C#
 	Terminal.Gui.dll!Terminal.Gui.Border.DrawTitle(Terminal.Gui.View view) Line 950	C#
 	Terminal.Gui.dll!Terminal.Gui.Border.DrawChildBorder(Terminal.Gui.Rect frame, bool fill) Line 718	C#
 	Terminal.Gui.dll!Terminal.Gui.Border.DrawContent(Terminal.Gui.View view, bool fill) Line 519	C#
 	Terminal.Gui.dll!Terminal.Gui.Window.Redraw(Terminal.Gui.Rect bounds) Line 300	C#
 	Terminal.Gui.dll!Terminal.Gui.Application.Refresh() Line 943	C#
 	Terminal.Gui.dll!Terminal.Gui.Application.RunMainLoopIteration(ref Terminal.Gui.Application.RunState state, bool wait, ref bool firstIteration) Line 1024	C#
 	Terminal.Gui.dll!Terminal.Gui.Application.RunLoop(Terminal.Gui.Application.RunState state, bool wait) Line 996	C#
 	Terminal.Gui.dll!Terminal.Gui.Application.Run(Terminal.Gui.Toplevel view, System.Func<System.Exception, bool> errorHandler) Line 1172	C#
 	Terminal.Gui.dll!Terminal.Gui.MessageBox.QueryFull(bool useErrorColors, int width, int height, NStack.ustring title, NStack.ustring message, int defaultButton, Terminal.Gui.Border border, NStack.ustring[] buttons) Line 310	C#
 	Terminal.Gui.dll!Terminal.Gui.MessageBox.Query(NStack.ustring title, NStack.ustring message, NStack.ustring[] buttons) Line 58	C#
 	MyApp.dll!MyApp.LoginViewModel.TestTargetConnectionAsync() Line 217	C#

SuperView is null, thus making the ColorScheme being null when being accessed in the first screenshot.

(View.cs)
image

This crash-exits the app.

(Note: since SuperView is marked nullable ("?") the ColorScheme should be marked nullable as well?)

Desktop (please complete the following information):

  • OS: Windows 11
  • Version: dev branch from 6 days ago: 8a90453

I looked at the recent commits and could see nothing that immediately looks like fixing this.

Edit: just pulled in the latest changes and the error persists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions