dwarfcorp icon indicating copy to clipboard operation
dwarfcorp copied to clipboard

Null reference while creating world preview texture [fairly common]

Open mklingen opened this issue 6 years ago • 4 comments

https://sentry.io/cfg/dwarfcorp/issues/772856984/?referrer=github_plugin

NullReferenceException: Object reference not set to an instance of an object.
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\GameStates\WorldGeneration\WorldGeneratorPreview.cs", line 426, in RegneratePreviewTexture
    Void RegneratePreviewTexture()
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\GameStates\WorldGeneration\WorldGeneratorPreview.cs", line 576, in PreparePreview
    Void PreparePreview(Microsoft.Xna.Framework.Graphics.GraphicsDevice)
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\GameStates\WorldGeneration\WorldGeneratorState.cs", line 375, in Update
    Void Update(DwarfCorp.DwarfTime)
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\GameStates\GameStateManager.cs", line 132, in Update
    Void Update(DwarfCorp.DwarfTime)
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\DwarfGame.cs", line 728, in Update
    Void Update(Microsoft.Xna.Framework.GameTime)

Object reference not set to an instance of an object.

mklingen avatar Feb 16 '19 23:02 mklingen

This is a tough one. The function is too large to pinpoint what's null here. So I'm going to break up this function into smaller chunks so that future crashes are more localized. Options include the Overworld map being null, the graphics device being null, the world generator being null, and so on.

mklingen avatar Feb 17 '19 13:02 mklingen

Broke up the function into parts to make localizing this crash easier in the future.

mklingen avatar Feb 17 '19 14:02 mklingen

Okay, localized this issue to SetNewPreviewtexture, line 479.

Sentry issue: DWARFCORP-106

mklingen avatar Feb 23 '19 17:02 mklingen

This means overworld.map is null just like in #1007 . Both of these bugs are pretty common, but I don't see a codepath that will make it happen.

mklingen avatar Feb 24 '19 15:02 mklingen