HomeWildfire Games

PushGuiPage support for passing a function instead of a function name.
Concern RaisedrP22676


PushGuiPage support for passing a function instead of a function name.
Allows coding the GUI without global functions which break prototype-oriented coding, refs #5322, fixing the concern in rP14496.

Supports stacked message boxes and removes the according workaround.
Change structree / civinfo switch-dialog code from rP21339 to perform the callback for page that actually registered the callback.
Ensure the parent that the callbackhandler is always called if the page is closed.
Merge PopGuiPage and PopGuiPageCB following that choice, incidentally leaving cleaner code.

Differential Revision: https://code.wildfiregames.com/D1684
Comments by: Yves, Vladislav, wraitii, leper

Event Timeline

elexis added inline comments.Aug 29 2019, 11:32 PM

This callback should, must have been updated too!

elexis added inline comments.Sep 22 2019, 12:49 AM

This closed without callback, the one below called with callback.
Now its always called with callback, so the callback must ignore the undefined return value instead of complaining about that.

wraitii raised a concern with this commit.Jun 7 2021, 4:41 PM
wraitii added a subscriber: wraitii.

90% sure this causes #5614. Need to figure serialisation of the function though...


This reads like it should crash in debug mode, but maybe it doesn't.


And here for a fun double-whammy which I think explains #5614: we 'deserialize' the callback from the original GUI script interface via the CGUIManager page into the current one. But if the page was hot loaded, that original is now destroyed. So this is actually broken twice.


Notice initData is cloned but not the function, which is suspicious

This commit now has outstanding concerns.Jun 7 2021, 4:41 PM

Note that so far I can tell, the actual crash is caused by Trying to recover the original scriptInterface from the private data of the JSContext.