Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#228 closed defect (released)

Crash with missing abilityID

Reported by: Henri Owned by: ibboard
Priority: minor Milestone: WarFoundry 0.1
Component: WarFoundry-API Version: Trunk
Keywords: Cc:
Blocked By: Blocking:

Description

So new toys to play with and I finally managed to crash the program. I know what the error is this time, I changed the abilityID in one place so it was referring to a non existing abilityID in the <abilities> list. A "nicer" handling would be nice though. I assume the same would be true for the <notes> tag?

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at IBBoard.WarFoundry.API.Objects.UnitType.AddAbility(Ability ability, Boolean isRequired) in C:\Users\Henri\Downloads\tortoise\warfoundry\IBBoard.WarFoundry.API\api\Objects\UnitType.cs:line 345
   at IBBoard.WarFoundry.API.Factories.Xml.WarFoundryXmlRaceFactory.LoadAbilitiesForUnitType(XmlElement elem, UnitType type) in C:\Users\Henri\Downloads\tortoise\warfoundry\IBBoard.WarFoundry.API\api\Factories\Xml\WarFoundryXmlRaceFactory.cs:line 334
   at IBBoard.WarFoundry.API.Factories.Xml.WarFoundryXmlRaceFactory.CreateUnitTypeFromElement(XmlElement elem, String id, Race parentRace) in C:\Users\Henri\Downloads\tortoise\warfoundry\IBBoard.WarFoundry.API\api\Factories\Xml\WarFoundryXmlRaceFactory.cs:line 125
   at IBBoard.WarFoundry.API.Factories.Xml.WarFoundryXmlRaceFactory.CompleteLoading(Race race) in C:\Users\Henri\Downloads\tortoise\warfoundry\IBBoard.WarFoundry.API\api\Factories\Xml\WarFoundryXmlRaceFactory.cs:line 80
   at IBBoard.WarFoundry.API.Objects.WarFoundryStagedLoadingObject.EnsureFullyLoaded() in C:\Users\Henri\Downloads\tortoise\warfoundry\IBBoard.WarFoundry.API\api\Objects\WarFoundryStagedLoadingObject.cs:line 47
   at IBBoard.WarFoundry.API.Objects.Race.HasCategoryOverrides() in C:\Users\Henri\Downloads\tortoise\warfoundry\IBBoard.WarFoundry.API\api\Objects\Race.cs:line 106
   at IBBoard.WarFoundry.GUI.WinForms.FrmMain.FrmMain_ArmyChanged(Army oldArmy, Army newArmy)
   at IBBoard.WarFoundry.API.ArmyChangedDelegate.Invoke(Army oldValue, Army newValue)
   at IBBoard.WarFoundry.GUI.WinForms.FrmMain.CreateNewArmy()
   at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.Command.Invoke()
   at System.Windows.Forms.Control.WmCommand(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4200 (NetFxQFE.050727-4200)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
WarFoundry
    Assembly Version: 0.0.1.29101
    Win32 Version: 0.0.1.29101
    CodeBase: file:///C:/Users/Henri/IBBoard.WarFoundry.GUI.WinForms/bin/Release/WarFoundry.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
log4net
    Assembly Version: 1.2.10.0
    Win32 Version: 1.2.10.0
    CodeBase: file:///C:/Users/Henri/IBBoard.WarFoundry.GUI.WinForms/bin/Release/log4net.DLL
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
IBBoard
    Assembly Version: 1.0.3623.29101
    Win32 Version: 1.0.3623.29101
    CodeBase: file:///C:/Users/Henri/IBBoard.WarFoundry.GUI.WinForms/bin/Release/IBBoard.DLL
----------------------------------------
IBBoardWF
    Assembly Version: 1.0.0.29101
    Win32 Version: 1.0.0.29101
    CodeBase: file:///C:/Users/Henri/IBBoard.WarFoundry.GUI.WinForms/bin/Release/IBBoardWF.DLL
----------------------------------------
IBBoard.WarFoundry.API
    Assembly Version: 0.0.1.29101
    Win32 Version: 0.0.1.29101
    CodeBase: file:///C:/Users/Henri/IBBoard.WarFoundry.GUI.WinForms/bin/Release/IBBoard.WarFoundry.API.DLL
----------------------------------------
ICSharpCode.SharpZipLib
    Assembly Version: 0.85.5.452
    Win32 Version: 0.85.5.452
    CodeBase: file:///C:/Users/Henri/IBBoard.WarFoundry.GUI.WinForms/bin/Release/ICSharpCode.SharpZipLib.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Change History (11)

comment:1 Changed 10 years ago by ibboard

Owner: set to ibboard
Status: newaccepted

comment:2 Changed 10 years ago by ibboard

(In r425) Re #228: Crash with missing abilityID

  • Quick fix to check if an ability ID doesn't match an ability and throw a standard error if it isn't found

TODO:

  • Need to check why it isn't handled by the attribute type (IDREF)
  • Need to test it works!

Problem shouldn't occur for <notes> because it is just a block of text and isn't referenced anywhere

comment:3 Changed 10 years ago by ibboard

(In r426) Re #228: Crash with missing abilityID

  • Fix build failure because of duplicate variable name - not sure why VS.net didn't complain before first commit

comment:4 Changed 10 years ago by ibboard

(In r442) Re #236: Race loading should fail cleanly if system doesn't exist

  • Add tests for race factory
  • Add test data that references non-existstent system
  • Make game system names for existing test data more distinct

Re #228: Crash with missing abilityID

  • Initial failing test

comment:5 Changed 10 years ago by ibboard

(In r444) Re #228: Crash with missing abilityID

  • Add test data files

comment:6 Changed 10 years ago by ibboard

(In r446) Re #228: Crash with missing abilityID

  • Separate out the actual loader implementation from the static "WarFoundryLoader" class
  • Add a setter method for the current loader
  • Create an abstract and default implementation of the Loader to reduce coupling and allow easier mocking/testing

comment:7 Changed 10 years ago by ibboard

(In r447) Re #228: Crash with missing abilityID

  • Update tests to match new refactored classes
  • Add expected message to missing game system error test
  • Re-implement missing ability test

comment:8 Changed 10 years ago by ibboard

(In r448) Re #228: Crash with missing abilityID

  • Add helper methods to get various supporting factories

comment:9 Changed 10 years ago by ibboard

Resolution: fixed
Status: acceptedclosed

(In r449) Fixes #228: Crash on invalid ability ID

  • Replace zipped Race and System files with unpackaged XML
  • Add helper class to create WarFoundry objects from XML files for tests
  • Use new helper classes to make test pass

comment:10 Changed 10 years ago by ibboard

released: noyes

Release as part of v0.1b6

comment:11 Changed 10 years ago by ibboard

Resolution: fixedreleased

Mark fix as released under a previous version

Note: See TracTickets for help on using tickets.