Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix infinite loop when listitem action is "Play" #14653
This fixes an infinite loop, noticed in the Game OSD, when clicking the "Play" item.
The Game OSD is a static list container. The top item has "Play" as a click action:
<control type="list" id="1103"> <content> <item id="2101"> <description>Pause / Resume button</description> <label>$LOCALIZE</label> <label2>Select + X</label2> <icon>osd/fullscreen/buttons/play.png</icon> <onclick>Play</onclick> </item>
The problem is the list container considers Play to be equivalent to Select. The GUI receives messages before the player, so it intercepts the Play action as a Select action. This executes the OnClick action, which is Play, and the process continues ad infinitum.
This bug was introduced in #14513.
Motivation and Context
Discovered while testing Beta 4.
How Has This Been Tested?
Tested on OSX with several cores.
Screenshots (if appropriate):
Types of change
This fixes an infinite loop, noticed in the Game OSD, when clicking the "Play" item. Actions are sent to the GUI before the player, and the GUI (CGUIBaseContainer) considers the "Play" action to be a "Select" action. It then resolves the "Select" action into "Play", which causes an infinite loop.
Well, let's think about this. "Play" is meant for the player, so whenever something is playing the player should receive the action. However, CApplication dispatches actions to Window Manager before the player. So, it's possible that CGUIBaseContainer checks if there's a player, and if not then handles the Play action. However, that adds an ugly dependency on player to the GUI code.
Alternatively, CApplication could send player actions to the player before the GUI. However, this probably has unintended side effects, and I wouldn't make this change for beta 4.
If we wanted to special-case the Game OSD, then we could have it intercept the Play command and dispatch it over the GUI bridge to the player that I built. However, this would still cause an infinite loop if a skin used the "play" action in a list container in a video or audio OSD.
I think the problem is deeper, it doesn't matter if a player is active, when we get to this line, the container tries to send all actions to OnClick(), and relies on OnClick() to only handle legitimate "click" actions, like Select or mouse clicks. This is a problem anytime the container control has a select-like action for its <onclick> actions in the skin. So, my guess is that there is currently an infinite loop if the item has
It actually makes sense for Kodi to infinite-loop in this case, because Select executes <onclick>, and <onclick> resolves to Select, to infinity. We could blacklist "Select" for on-click actions, but I don't think we should blacklist "Play", because Play has behavior apart from Select. #14513 makes Play behave like Select, hence the infinite loop.