zeta0134 / LuaGB

A gameboy emulator written in pure Lua. Work in progress.
BSD 3-Clause "New" or "Revised" License
412 stars 35 forks source link

Pressing XZ at the same time in main menu causes crash. #5

Closed ghost closed 7 years ago

ghost commented 7 years ago
filebrowser.lua:195: attempt to concatenate local 'cursor_item' (a nil value)
Traceback:
filebrowser.lua:195: in function 'select_at_cursor'
filebrowser.lua:220: in function 'keyreleased'
main.lua:391: in function <main.lua:383:>
[C]: in function 'xpcall'

This applies to the Windows version.

ghost commented 7 years ago

This appears to only happen if there is no games available.

sumit0190 commented 7 years ago

I haven't played around with the emulator yet, but one glance at the code tells me that this can be reproduced by just pressing X on a screen where no games are available (on any OS). It's because there is no 'nil check' in the select_at_cursor function - ideally, the code from line 195 onwards (in filebrowser.lua) would be executed only if cursor_item is non-nil. There should probably be a few other checks as well, I think. @zeta0134 is my analysis correct?

zeta0134 commented 7 years ago

Aye, your analysis was spot on. Fixed by: https://github.com/zeta0134/LuaGB/commit/8c7fcc0153ecd6f0b7442cef8d110f36a923c62f