Calling ActivateWindow() from <onunload>
#1
Hi,

I am running a kodi Helix 14.02 build, and I am trying to call ActivateWindow() from the <onunload> tag in my VideoFullScreen.xml window definition, trying to invoke a specific window on video exit.

With all the windows I tried, kodi enters an infinite loop and ends up crashing. The only exception seems to be dialogs (it works with "movieinformation" for instance).

Is this a bug or am I missing something?
Reply
#2
Have you tried using a conditional onload for all the other windows where the condition is Window.Previous(fullscreenvideo)?
Reply
#3
(2015-05-15, 21:57)pbureau Wrote: Hi,

I am running a kodi Helix 14.02 build, and I am trying to call ActivateWindow() from the <onunload> tag in my VideoFullScreen.xml window definition

when you exit fullscreen, kodi will activate the previous window.
if you add add another ActivateWindow() through onunload on top of it, odd things can happen i guess.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#4
ok, after a look at the code, this behavior is normal.
  • unload actions are executed in the: OnMessage(), GUI_MSG_WINDOW_DEINIT, callback for the current window.
  • That calls CGUIAction::ExecuteActions which loops through all the <onunload> statements
  • When ActivateWindow() is called, it runs CGUIWindowManager::ActivateWindow_Internal()
  • This calls CloseWindowSync() for the current window, which runs CGUIWindow::Close_Internal()
  • Finally this sends a GUI_MSG_WINDOW_DEINIT message... closing the loop

I am not sure if this was intended from the developers, but it seems like a pretty open way to crash the application with a bad xml file. At the very least it should be documented.

I am going to propose a patch for this, a submit a pull request...
Reply
#5
(2015-05-15, 23:59)pbureau Wrote: ok, after a look at the code, this behavior is normal.
  • unload actions are executed in the: OnMessage(), GUI_MSG_WINDOW_DEINIT, callback for the current window.
  • That calls CGUIAction::ExecuteActions which loops through all the <onunload> statements
  • When ActivateWindow() is called, it runs CGUIWindowManager::ActivateWindow_Internal()
  • This calls CloseWindowSync() for the current window, which runs CGUIWindow::Close_Internal()
  • Finally this sends a GUI_MSG_WINDOW_DEINIT message... closing the loop

I am not sure if this was intended from the developers, but it seems like a pretty open way to crash the application with a bad xml file. At the very least it should be documented.

I am going to propose a patch for this, a submit a pull request...
You are correct. Thanks for helping out!
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#6
no problem.

By the way, is the <previouswindow> tag actually intended to provide this functionality? Which means ActivateWindow() is actually not meant to be supported inside the <onunload> tag??

This would be fine, except it seems that <previouswindow> will not work for dialogs (such as "movieinformation"), is this normal?
Reply
#7
previouswindow can be used to override the window stack afaik. I´m not 100% sure what you intend to do but there are probably nicer ways than putting ActivateWindow() into an <onunload> element. Anyways, no matter if your approach makes sense or not, if you are able to crash Kodi with some xml code then it should get fixed. Smile
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#8
agreed, but do you think the fix should be to enable usage of ActivateWindow() inside <onunload>, or should <onunload> ignores ActivateWindow() actions (probably throwing a LOGINFO), thus only preventing the infinite loop?
Reply
#9
either enabling the usage of ActivateWindow() or ignoring the call in case it would lead to a crash (for dialogs this works fine for example). Ignoring it in general is not a good idea since that could break skins.
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#10
ok I have prepared (and going to submit) a patch for this, however I don't think that trying to support ActivateWindow() from the <onunload> tag actually makes sense. When the onunload actions are invoked, we are already in the ActivateWindow() execution of the stack previous windows, that would need to be aborted and replaced by the action defined window. The fact that dialogs don't break the application is more a side effect than because it has been designed that way.
The <previouswindow> tag is really meant to provide this functionality in skins...

The proposed patch simply ignores ActivateWindow() statements.
Reply

Logout Mark Read Team Forum Stats Members Help
Calling ActivateWindow() from <onunload>0