Menu

#1913 Exception in getUnitImageIcon

Unspecified
closed-duplicate
nobody
None
5
2013-01-14
2010-06-18
Anonymous
No

The attached saved game consistently throws an exception while "Waiting for Sioux":

AWT-EventQueue-0[1] java.lang.NullPointerException
at net.sf.freecol.client.gui.ImageLibrary.getUnitImageIcon(ImageLibrary.java:1166)
at net.sf.freecol.client.gui.ImageLibrary.getUnitImageIcon(ImageLibrary.java:1207)
at net.sf.freecol.client.gui.ImageLibrary.getUnitImageIcon(ImageLibrary.java:1178)
at net.sf.freecol.client.gui.GUI.displayUnit(GUI.java:2777)
at net.sf.freecol.client.gui.GUI.displayMap(GUI.java:1338)
at net.sf.freecol.client.gui.GUI.display(GUI.java:951)
at net.sf.freecol.client.gui.Canvas.paintComponent(Canvas.java:376)

Discussion

  • Nobody/Anonymous

     
  • Nobody/Anonymous

    This is running 0.9.x at revision 7031.

     
  • Nobody/Anonymous

    Digging a bit further, jdb tells me unitType is null at line 1166, but I don't see how it can be - there is a check for null at line 1337 of displayMap.

    Memory corruption or a threading problem? Any suggestions on what to look at next?

     
  • Nobody/Anonymous

    Minimal steps to reproduce the exception:
    load game
    end turn
    close turn report
    move NW scout to Phah Sapa and ask to speak with the chief
    end turn
    next sioux turn hits the exception

     
  • Nobody/Anonymous

    I tracked this down to a brave unit that somehow ends up with a null UnitType and a null Owner. Earlier in the log the same unit has a non-null UnitType and Owner.

     
  • Nobody/Anonymous

    net.sf.freecol.common.model.SimpleCombatModel getDefensiveModifiers
    WARNING: getDefensiveModifiers: unit:16481 (model.unit.brave/DEFAULT) 1/1 ServerPlayer[name=Taoyateduta,serverID=player:29,conn=DummyConnection[Server-Server-Taoyateduta]]
    Sat Jun 26 22:32:23 MDT 2010
    Thread ID: 132
    ...
    net.sf.freecol.client.control.InGameInputHandler$UnitMoveAnimationCanvasSwingTask doWork
    WARNING: Unit unit:16481 has no owner
    Sat Jun 26 22:32:23 MDT 2010
    Thread ID: 11
    net.sf.freecol.client.control.InGameInputHandler$SwingTask run
    FINEST: Swing task net.sf.freecol.client.control.InGameInputHandler$UnitMoveAnimationCanvasSwingTask returned null
    Sat Jun 26 22:32:23 MDT 2010
    Thread ID: 11
    net.sf.freecol.common.networking.Connection$1 run
    WARNING: Message handler failed!
    Sat Jun 26 22:32:23 MDT 2010
    Thread ID: 135
    Stack trace:
    java.lang.IllegalStateException: Unit unit:16481 has no owner
    at net.sf.freecol.common.model.Unit.contactAdjacent(Unit.java:2073)
    at net.sf.freecol.common.model.Unit.setLocation(Unit.java:2055)
    at net.sf.freecol.client.control.InGameInputHandler.opponentMove(InGameInputHandler.java:313)
    at net.sf.freecol.client.control.InGameInputHandler.handle(InGameInputHandler.java:117)
    at net.sf.freecol.common.networking.Connection$1.run(Connection.java:507)

     
  • Mike Pope

    Mike Pope - 2010-06-29

    Looks nasty. Alas, I could not load the attached save game with either current trunk or svn.7031.

     
  • Nobody/Anonymous

    This patch works around the exception by ignoring the offending unit:

    Index: src/net/sf/freecol/client/control/InGameInputHandler.java

    --- src/net/sf/freecol/client/control/InGameInputHandler.java (revision 7058)
    +++ src/net/sf/freecol/client/control/InGameInputHandler.java (working copy)
    @@ -303,7 +303,15 @@
    new RefreshTilesSwingTask(unit.getTile(), toTile).invokeLater();
    }
    if (getFreeColClient().getMyPlayer().canSee(toTile)) {
    - unit.setLocation(toTile);
    + if (unit.getOwner() == null) {
    + logger.warning("unit " + unit.getId() + " has null owner");
    + }
    + else if (unit.getType() == null) {
    + logger.warning("unit " + unit.getId() + " has null type");
    + }
    + else {
    + unit.setLocation(toTile);
    + }
    } else {
    unit.dispose();
    }

     
  • Mike Pope

    Mike Pope - 2010-06-30

    Alas, no improvement with 7058. The unit without an owner is indicative of some nasty corruption, and it looks to me as if it is in the save game. Do you perhaps have a save game from a move or moves before the attached one?

     
  • Nobody/Anonymous

    Yes, I do. However, I don't see a way to add a file to this bug report. What am I missing?

     
  • Mike Pope

    Mike Pope - 2010-07-01

    You need to log in. The "Add a File" box does not appear for guest/nobody.

     
  • Nobody/Anonymous

    According to sf support:
    "As a spam prevention measure, only project administrators and the
    bug submitter are able to add files to Tracker tickets."

    I logged in but still couldn't add any files. I can provide them via email if that helps.

     
  • Mike Pope

    Mike Pope - 2010-09-01

    This artifact has been marked as a duplicate of artifact 3041198 with reason:
    Same bug. prefer later

     
  • Mike Pope

    Mike Pope - 2010-09-01
    • status: open --> closed
     
  • Mike Pope

    Mike Pope - 2010-09-01
    • status: closed --> closed-duplicate
     
  • Mike Pope

    Mike Pope - 2013-01-14
    • Milestone: --> Unspecified
     

Log in to post a comment.