Hyphen-ated / RebirthItemTracker

Uses the log.txt file to track item pickups in Binding of Isaac: Rebirth.
BSD 2-Clause "Simplified" License
121 stars 26 forks source link

Fixed a runtime exception when running via source #111

Closed ticklemynausea closed 8 years ago

ticklemynausea commented 8 years ago

When running via source (I did not attempt to build the project), it exited with the following exception:

Traceback (most recent call last):
    File ".\item_tracker.py", line 229, in main
        rt.run()
    File ".\item_tracker.py", line 80, in run
        event_result = drawing_tool.handle_events()
    File ".\view_controls\view.py", line 116, in handle_events
        self.__reflow()
    File ".\view_controls\view.py", line 272, in __reflow
        items_to_flow = [x for x in self.state.item_list if self.show_item(x)]
AttributeError: 'NoneType' object has no attribute 'item_list'

The simple fix in this commit made everything run correctly.

Environment details: Windows 10 Python 2.7.11 (Anaconda 4.0.0 64-bit)) Pygame 1.9.2a0 (from https://conda.binstar.org/krisvanneste/win-64/pygame-1.9.2a0-py27_0.tar.bz2)

ticklemynausea commented 8 years ago

Maybe I should add that by "running via source" I mean using the command python run_item_tracker_directly.py

viroulep commented 8 years ago

I somehow ran into that the other day but didn't manage to reproduce it/debug it, so hopefully someone did :)

Now that I think about it the actual issue here seems to be that __reflow assumes that state is not none (if there is no state there is no item to reflow), so one other way to fix that would be to call the function on line 116 only if state is not none, like on line 163.

Anyway with your fix the function does nothing if there is no state, so it's safer!