Page MenuHomeWildfire Games

Gamesetup tab crash, when holding hotkey
ClosedPublic

Authored by bb on Jan 22 2018, 2:15 PM.

Details

Summary

When holding the Alt+S/W hotkey and loading gamesetup, it will crash, since the buttons are only initialized after the first tick (this is required in gamesetup since it is waiting on netmessages), but the hotkey already is active and tries to use uninitializes variables, checking for the tabsCount solves the issue (and doesn't break other pages)

Test Plan

Hold Alt+S/W to see the crash and not crash with the patch
Make sure other pages still work
nitpick about a prototype

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bb created this revision.Jan 22 2018, 2:15 PM
elexis added a subscriber: elexis.Jan 22 2018, 2:54 PM

Error reported here:
https://code.wildfiregames.com/rP20945#27266

ERROR: JavaScript error: gui/gamesetup/gamesetup.js line 2248
TypeError: g_SettingsTabsGUI[g_TabCategorySelected] is undefined
updateGUIObjects@gui/gamesetup/gamesetup.js:2248:1
initGUIObjects/<@gui/gamesetup/gamesetup.js:1204:4
selectPanel@gui/common/tab_buttons.js:74:2
placeTabButtons@gui/common/tab_buttons.js:51:2
initGUIObjects@gui/gamesetup/gamesetup.js:1196:1
onTick@gui/gamesetup/gamesetup.js:1909:3
__eventhandler388 (tick)@setupWindow tick:0:1

binaries/data/mods/public/gui/common/tab_buttons.js
4 ↗(On Diff #5418)

unavoidable?
Can't we chek for g_SettingsTabsGUI[g_TabCategorySelected] or similar?

bb added inline comments.Jan 22 2018, 5:31 PM
binaries/data/mods/public/gui/common/tab_buttons.js
4 ↗(On Diff #5418)

Well the problem is that selectNextTab starts changing the value of g_TabCategorySelected, without knowing the length (and so currupting the value of g_TabCategorySelected),
Also we get errors before:

ERROR: JavaScript error: gui/common/tab_buttons.js line 74
TypeError: g_OnSelectTab is not a function
  selectPanel@gui/common/tab_buttons.js:74:2
  selectNextTab@gui/common/tab_buttons.js:60:1
  __eventhandler45 (press)@__internal(10) press:0:1

Instead of having the init flag, we can also check for the g_TabCategoryCount instead.

bb updated this revision to Diff 5432.Jan 22 2018, 8:53 PM
bb edited the summary of this revision. (Show Details)

Use the Count

Owners added a subscriber: Restricted Owners Package.Jan 22 2018, 8:53 PM
elexis accepted this revision.Jan 22 2018, 10:11 PM
This revision is now accepted and ready to land.Jan 22 2018, 10:11 PM
This revision was automatically updated to reflect the committed changes.