Skip to content
This repository

Keep GUIControls alive after window deinit #1283

Merged
merged 21 commits into from over 1 year ago

6 participants

Michal Piechowiak jmarshallnz Voyager1 Joakim Plate Tristan Fischer Trent Nelson
Michal Piechowiak
Collaborator
pieh commented August 12, 2012

This is resurrection of #127 in much more complete state:

Window's controls are being deleted on window deinit. This results in loading xml, resolving includes, parsing resolved xml and creating controls everytime user activate window.

This will allow to keep controls objects in memory on window deinit. It also will store xml windows root node that could be used if load type is set to load_on_demand (old style - few windows are still like this) or if include condition have changed value.

Some numbers (tested on raspberry pi with slow sd card where it will have biggest impact I guess): compare alloc resources time for first and second window inits. (I didn't really gather data, just ran xbmc 3 times and given that results were similliar I called it done)

===== Results (numbers from Raspberry Pi) ====

  1. Home Window

     -- First window init will be same as usual --

    00:02:33 T:1096794832   DEBUG: ------ Window Init (Home.xml) ------
    00:02:33 T:1096794832    INFO: Loading skin file: Home.xml, load type: on demand and keep in memory after window deinit
    00:02:33 T:1096794832   DEBUG: Load Home.xml: 665.98ms
    00:02:34 T:1096794832   DEBUG: Alloc resources: 723.72ms  (666.55 ms skin load)

     -- Second window init --

    00:03:24 T:1096794832   DEBUG: ------ Window Init (Home.xml) ------
    00:03:24 T:1096794832   DEBUG: Window Home.xml was already loaded
    00:03:24 T:1096794832   DEBUG: Alloc resources: 22.07m

  2. Video Nav

    00:03:18 T:1096794832   DEBUG: ------ Window Init (MyVideoNav.xml) ------
    00:03:18 T:1096794832    INFO: Loading skin file: MyVideoNav.xml, load type: on demand and keep in memory after window deinit
    00:03:19 T:1096794832   DEBUG: Load MyVideoNav.xml: 776.83ms
    00:03:19 T:1096794832   DEBUG: Alloc resources: 827.03ms  (777.33 ms skin load)

    00:03:30 T:1096794832   DEBUG: ------ Window Init (MyVideoNav.xml) ------
    00:03:30 T:1096794832   DEBUG: Window MyVideoNav.xml was already loaded
    00:03:30 T:1096794832   DEBUG: Alloc resources: 27.48m

On android (skin.retouched) Home.xml was loaded 1st time: 126ms and 2nd time: 5ms (that's total alloc resources time). On my desktop with ssd - home.xml = 1st time: 42ms, 2nd time: 4ms. So it's not that spectacular everywhere. Note: alloc resources times don't include time spent in OnWindowInit (f.e. video nav window fetch directory there)!

Here's list of windows that weren't yet adjusted/tested if they will work "as-is":

Still on to-do list but not really high priority:
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: screencalibration (file: SettingsScreenCalibration.xml, ID: 10011)
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: filestackingdialog (file: DialogFileStacking.xml, ID: 12008)

Didn't have any karaoke samples so at least for now I leave them as they are with old style xml loading every init. Do they still work at all?
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: karaokeselector (file: DialogKaraokeSongSelector.xml, ID: 10143)
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: karaokelargeselector (file: DialogKaraokeSongSelectorLarge.xml, ID: 10144)
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: karaoke (file: MusicKaraokeLyrics.xml, ID: 12009)

For no-xml windows load type doesn't matter so they can stay as they are.
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: teletext (file: no xml file, ID: 10600)
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: unkown window (file: no xml file, ID: 97) <= Dim Screensaver Window
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: unkown window (file: no xml file, ID: 98) <= Debug Overlay Window
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: screensaver (file: no xml file, ID: 12900)

CGUIDialogSubMenu class used only as base for "submenu" type custom windows (which wasn't used by any of few skins I have: confluence, aeon-nox, xeebo). No DialogSubMenu.xml in confluence. Nuke that window?
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: submenu (file: DialogSubMenu.xml, ID: 10105)

Used only after playing with GUISetting that aren't shown in GUI. No DialogAccessPoints.xml in confluence. Nuke that window?
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: accesspoints (file: DialogAccessPoints.xml, ID: 10141)

Loaded and shown once - no sense in keeping it in memory.
00:02:30 T:1096794832   DEBUG: GUIWindowManager: LOAD_ON_DEMAND window: startup (file: Startup.xml, ID: 12999)

And finally - my branch currently contains 2(3) last temporary commits (they will be removed later) to
1. help me notice what windows weren't adjusted yet (it generated window list above)
2. enable/disable feature on runtime (in gui settings) to check what impact it have
(3). add window loadtype to log on window load (depends on how verbose we want to be)

jmarshallnz
Owner

Ok, main thing is I think we need to clearly identify where we need overriding in the subclasses. Seems to me we have:

  1. After XML load and before control parsing (for python label parsing).
  2. After control parsing (filling default content that anims and control state might need). Should run once we have controls either from in memory or from a load.
  3. After window is up, anims are all setup and we're ready to go (filling in content). Should run every init.

... window cycle ...

  1. After window close animation and before controls are cleared (reset controls to default state).
  2. After controls are cleared and before unload (not sure if needed)
  3. After XML unload.

Not sure about 2/3 vs 5/6

Michal Piechowiak
Collaborator
pieh commented August 13, 2012

I don't understand what You mean with "python label parsing" (or I'm propably totally unaware that we do something like that?).

I don't think we should change where/when we call existing callbacks (this would propably cause serious regressions which I already faced once and it took me quite a long time to finalize it). But adding new callbacks would be ok I think (and wouldn't hurt).

jmarshallnz
Owner

IIRC winxml windows parse for existing Localise stuff and bumps the string IDs up as needed?

Michal Piechowiak
Collaborator
pieh commented August 13, 2012

Right, found it - CGUIPythonWindowXML is overriding CGUIWindow::LoadXML. It manipulates directly on xml string (before parsing) to replace SCRIPT### to proper ID - do we want callback that will pass xml as string so it can be manipulated? Doesn't seem nice to me.

Michal Piechowiak
Collaborator
pieh commented August 14, 2012

Added bunch of changes (additional commits will be squashed later). Wanted to keep comment history so we can track what is already taken care of.

jmarshallnz
Owner

Looks like we can do cases 2 and 3 above via OnInitWindow, as that runs every time, right? So we could do:

DerivedClass::OnInitWindow()
{
// do whatever needs doing in 2

BaseClass::OnInitWindow() // sets up animations etc.

// do whatever needs doing in 3
}

So I don't think we need a new callback there.

jmarshallnz
Owner

Changes look good

added some commits February 15, 2012
Michal Piechowiak allow include resolver to store checked include conditions and their …
…values into map<conditionID:int, value:bool>

store conditions and values used to resolve includes in CGUIWindow
added CGUIInfoManager::ConditionsChangedValues method
fb6a3f0
Michal Piechowiak change bool m_loadOnDemand to LOAD_TYPE m_loadType 5671a6a
Michal Piechowiak allow not to free memory (destroy controls objects) when exiting window
added additional checks in AllocResources - we have to load .xml file if:
 - load type is set to LOAD_EVERY_TIME (all windows use it by default)
 - window is loaded and any of include condition have changed value
 - window isn't loaded

we have to unload window before loading if window wasn't unloaded before and include conditions have change value(s)
afffab0
Michal Piechowiak store and reuse window xml root node
this allows to avoid reading and parsing xml file in windows we already used before and are loaded on demand or their include conditions have changed values
996bd17
Michal Piechowiak regression fix: override SetInitialVisibility() in CGUIBaseContainer …
…to force restoring static items before restoring control states ( in CGUIWindow::OnInitWindow, SetInitialVisibility() is called before RestoreControlStates() )

not need to call UpdateStaticItems() if we are loading static items from .xml as we do it before SetInitialVisibility is called and it will be called there
f2e9d06
Michal Piechowiak adjust GUIDialogContextMenu: cleaning up initialization/deinitializat…
…ion of dialog

- we need additional members to remember window coordinates (these are fetched while loading window .xml file and later are changed when setting position of ContextMenu) and size of background image
- we don't need to call SetInitialVisibility - it's alreadu done in CGUIWindow::OnWindowInit
- we need to manually remove choice buttons in OnDeinitWindow
- we need to store size of background image to properly set its size it in consequent showings
e30dbc2
Michal Piechowiak keep these windows in memory, they're ready as-is 4ce5d78
Michal Piechowiak adjust GUIDialogBoxBase: store heading,lines,choices and set them whe…
…n initing window and if dialog is already active
158c99b
Michal Piechowiak adjust GUISlideShow: move stoping background loader to window deinit 53eabbf
Michal Piechowiak adjust GUIDialogMediaSource: clear list with paths on deinit bb3a2bc
Michal Piechowiak adjust GUIDialogSelect: don't reset GUIViewControl when leaving windo…
…w, clear it

reset it when we unload window
b5843d8
Michal Piechowiak adjust GUIDialogNetworkSetup: change control types only when we load …
…window, fill/clear protocol spinner when we init/deinit window
d260bfb
Michal Piechowiak adjust GUIDialogPeripheralManager: we would run OnInitWindow twice du…
…e to not consuming GUI_MSG_WINDOW_INIT message

also move init actions to OnInitWindow callback
4e00b80
Michal Piechowiak adjust GUIDialogVideoScan: hide progress controls if not used 83a3f44
Michal Piechowiak adjust GUIDialogSlider: nullify callbacks on window deinit 5eadd51
Michal Piechowiak adjust GUIWindowFullscreen: don't toggle DynamicResourceAlloc, shuffl…
…e deinit order a little and let generic window code to handle control unloading/freeing
32fdcd9
Michal Piechowiak adjust GUIDialogTextViewer: reset textarea and heading controls after…
… deinit
aa037df
Michal Piechowiak adjust GUIDialogSmartPlaylistEditor: move playlist type specific conf…
…iguration to OnInitWindow
00bd5fb
Michal Piechowiak adjust GUIDialogSmartPlaylistRule: clear rule spinner before filling …
…it, clear rule and operand spinner on deinit and try to change value button to edit control just once on window load
5649658
Michal Piechowiak adjust GUIWindowSystemInfo: clear labels on window deinit d11b741
Michal Piechowiak log: add window loadType to debug log on window load 7614940
Michal Piechowiak pieh merged commit 2cc5bc9 into from September 08, 2012
Michal Piechowiak pieh closed this September 08, 2012
Voyager1
Collaborator

I'm noticing problems with stale information still being displayed in some of the labels on the Video Info dialog (CGUIDialogVideoInfo), e.g. the file path, the media labels (1080, xvid, bluray etc.) and others. When some label is "empty" the next time, it does not replace what was there the last time.

I believe that it has to do with this new feature. Just like what was done with other windows/dialogs part of this change, we probably need to clear the labels in the DEINIT event?

Michal Piechowiak
Collaborator

right, I must have missed it, will fix it

Voyager1
Collaborator

just confirming that as a temp fix, I commented out m_loadType = KEEP_IN_MEMORY; in the CGUIDialogVideoInfo constructor.

Voyager1
Collaborator

Same problem with CGUIDialogMusicInfo. Just get the album info for one, then for the next. Doesn't update.

Michal Piechowiak
Collaborator

hmm, this is weird - what skin are you using?

Voyager1
Collaborator

Confluence, the standard!

Voyager1
Collaborator

just tested with commenting out the keep in memory, fixes the issue again for the album info (CGUIDialogMusicInfo)

Voyager1
Collaborator

you have to look closely, it's the artist, genre, rating, year and the artwork that remain the same as the first one you opened...

Michal Piechowiak
Collaborator

right, it's something with rendering - if you'll hover mouse on it it will refresh

Voyager1
Collaborator

i saw that too. (although I used the keyboard arrows). So how to fix?

Joakim Plate
Collaborator
Michal Piechowiak
Collaborator

this is problem with controls in containers - they refresh only when layout is marked invalid, will fix that
EDIT: well that's not the problem - will fix layout not being invalidated

Michal Piechowiak
Collaborator

fixed in 8b796ee

Voyager1
Collaborator

just tried it. it's not entirely fixed: the media flags still don't update correctly. Eg. the first one I view is bluray, the next one not, but the flag is still there.

EDIT: same with the music albums. Try an album with cover art, then another without. The first album art is still displayed...

Michal Piechowiak
Collaborator

@Voyager-xbmc
here's my proposed fix for that pieh@affcec9 - it fixes given issue, just not sure it won't cause another. Won't push it yet because i'm going off for the weekend and don't won't to introduce any unknown bug when I'm bit available.

Voyager1
Collaborator

@pieh - thanks for the great work. I was close to the same solution (only the 2nd if though) but I think this is it. I'll play with it - happy to report experiences after the weekend :-)

jmarshallnz
Voyager1
Collaborator

@jmarshallnz - the issue is that pieh's PR altered the way windows get loaded. Previously they were loaded every time, now they stay in memory and get reused, thereby speeding up the GUI. This means that controls don't get reinitialised via constructor. In between inits an image on a window should be able to change, e.g. the album art, the media flag images... The problem was that if we went from an "old" image with an actual texture in it (e.g the 720.png flag) to a "new" image path that was empty (e.g. no flag set), somehow it didn't change the texture. By debugging I found that the m_currentTexture would indeed be empty, but the m_texture.m_info filename was still the old one (e.g. 720.png). It turned out m_texture.SetFileName wasn't called, nor did we mark the dirtyregion.

Edit:
don't know if this is useful, but anyway, I first tried to resolve it by calling m_texture.setFileName in CGUIImage::FreeTextures, to resolve the issue of the old filename still being there, but that didn't help. You also need to mark the image dirty, but that caused too many issues so I abandoned.

Michal Piechowiak
Collaborator
jmarshallnz
Voyager1
Collaborator

tried this, and it works. Just don't empty the m_currentTexture anymore, so the comparison with strFileName in ::SetFileName works properly. I checked and m_currentTexture isn't much used anywhere else. I also tried messing with clearing out the texture info (m_info.filename) in the free texture method, but that creates a lot of issues with the gui...

void CGUIImage::FreeTextures(bool immediately /* = false */)
{
  m_texture.FreeResources(immediately);
  for (unsigned int i = 0; i < m_fadingTextures.size(); i++)
    delete m_fadingTextures[i];
  m_fadingTextures.clear();
  //m_currentTexture.Empty(); <-- remove this!
} 
jmarshallnz
Voyager1
Collaborator

the problem is more than just keeping them in sync.
Here's what happens if you call m_texture.SetFilename in CGUIImage::FreeTextures:

http://imageshack.us/a/img703/5720/screenshot001yo.png

Voyager1
Collaborator

and when you move the m_texture.SetFileName(m_currentTexture); as the first line to CGUIImage::AllocResources, results are even worse. Lots of textures missing.

http://imageshack.us/a/img152/6313/screenshot000u.png

Somehow, I think that my proposal to NOT clear m_currentTexture is the least intrusive. This member variable is just used to carry the latest texture filename used, nothing else. Not clearing it means you can appropriately track a change from a non-empty to an empty picture...

Michal Piechowiak
Collaborator

@Voyager-xbmc
this line ( abbacb5 ) was added as part of the fix for http://trac.xbmc.org/ticket/9926 . Not sure if it's ok to remove it completely, so here's my next attempt: pieh@13c843b

this won't make textures dissapear - problem with disappearing textures is that if texture path is constant (as in no InfoLabels are used, so all confluence textures) we will only update texture once - when we create image control. This won't break it because constant texture path doesn't use m_currentFile (leaving it empty) so when I try to set file name in ::FreeTextures it won't have any effect (as new and old path are both empty)

it still isn't as nice as I would like it (mostly part that it won't break constant textures "only by accident"), but at least better than previous "fix"

jmarshallnz

Isn't that identical to calling m_texture.SetFilename("") after resetting m_current texture ?

Voyager1
Collaborator

@jmarshallnz : I would say it's almost identical, with the exception of two things: checking the value already in m_currentTexture (don't do anything if already empty) and the dirty region handling. With pieh's solution working fine, I have adapted it as follows. Note that without the if (!m_currentTexture.Equals("")) you get again a lot of empty/missing images as in my screenshots above.

void CGUIImage::FreeTextures(bool immediately /* = false */)
{
  m_texture.FreeResources(immediately);
  for (unsigned int i = 0; i < m_fadingTextures.size(); i++)
    delete m_fadingTextures[i];
  m_fadingTextures.clear();
  if (!m_currentTexture.Equals(""))
  {
    m_currentTexture = "";
    if (m_texture.SetFileName(m_currentTexture))
      MarkDirtyRegion();
  }
}
jmarshallnz
Voyager1
Collaborator

You're right. Reduced it to the following, and still works ok:

void CGUIImage::FreeTextures(bool immediately /* = false */)
{
  m_texture.FreeResources(immediately);
  for (unsigned int i = 0; i < m_fadingTextures.size(); i++)
    delete m_fadingTextures[i];
  m_fadingTextures.clear();
  if (!m_currentTexture.IsEmpty())
  {
    m_currentTexture.Empty();
    m_texture.SetFileName(m_currentTexture);
  }
}

So it seems that the if guard is what is making the difference. Probably FreeTextures is called when m_currentTexture is already empty but m_texture is not, in which case without the if guard we would empty the m_texture's filename, thus causing the missing images from my screenshots above.

Voyager1
Collaborator

Additional info: So it seems to work fine with the code I posted above. However, there are now still cases where m_currentTexture is empty while m_texture's filename is not. Apparently m_texture's filename is set in a number of places in CGUIImage, without syncing m_currentTexture, e.g. the contstructors, CGUIImage::Process and CGUIImage::SetInfo. I tried to make sure we sync it in all those places, but then the problem I described with the screenshots reappears. Similarly, I removed m_currentTexture everywhere and replaced it with m_texture.GetFileName() - same issue. I don't know the code enough, but it seems that those two are not really meant to be in sync at all times.

Michal Piechowiak
Collaborator

Additional info: So it seems to work fine with the code I posted above. However, there are now still cases where m_currentTexture is empty while m_texture's filename is not. Apparently m_texture's filename is set in a number of places in CGUIImage, without syncing m_currentTexture, e.g. the contstructors, CGUIImage::Process and CGUIImage::SetInfo. I tried to make sure we sync it in all those places, but then the problem I described with the screenshots reappears. Similarly, I removed m_currentTexture everywhere and replaced it with m_texture.GetFileName() - same issue. I don't know the code enough, but it seems that those two are not really meant to be in sync at all times.

There are 2 cases: we use constant texture path: f.e. "floor.png" or we use dynamic texture path: f.e. "$INFO[ListItem.Icon]". First one will just set texture's filename in CGUI::SetInfo without using m_currentTexture at all (so it will stay empty) - in this case we can't simply reset texture's filename as we won't update texture next time we load window (that's why there are missing textures as texture has empty path). Second one will be evaluated each frame and compared to m_currentTexture and update both m_currentTexture and texture object if it changed - so as long as we keep m_texture and m_currentTexture in sync it will be good.

So IMO good solution would be to both clear m_currentTexture and m_texture and set texture path in method that is called when window is inited. There's obviously catch as this method would be ::AllocResources but CGUIImage has DynamicResourceAlloc flag set which means AllocResoures won't be called on window init and image control itself is in charge of allocating resources. I will try to get around this and see what I can come up with.

Michal Piechowiak
Collaborator

here's another take on it: pieh@a5b3b36

Voyager1
Collaborator

tried it, and looks good. I don't know if there is a real reason to keep m_currentTexture empty for the constant textures. In any case I tried your solution, it works. I have also tried modifying it to also sync m_currentTexture in ::AllocResources and that works too.

    if (m_info.IsConstant()) 
    {
      m_texture.SetFileName(m_info.GetLabel(0)); 
      m_currentTexture = m_texture.GetFileName();
    }
jmarshallnz
Voyager1
Collaborator

@jmarshallnz - just to make sure, you mean it like this?

void CGUIImage::FreeTextures(bool immediately /* = false */)
{
  m_texture.FreeResources(immediately);
  for (unsigned int i = 0; i < m_fadingTextures.size(); i++)
    delete m_fadingTextures[i];
  m_fadingTextures.clear();
  if (!m_info.IsConstant()) // constant textures never change 
  {
    m_currentTexture.Empty();
    m_texture.SetFileName(m_currentTexture);
  }
}
jmarshallnz
Voyager1
Collaborator

@jmarshallnz - got it. This works too. Thanks!!

void CGUIImage::FreeTextures(bool immediately /* = false */)
{
  m_texture.FreeResources(immediately);
  for (unsigned int i = 0; i < m_fadingTextures.size(); i++)
    delete m_fadingTextures[i];
  m_fadingTextures.clear();
  m_currentTexture.Empty();
  if (!m_info.IsConstant()) // constant textures never change 
    m_texture.SetFileName("");
}
Michal Piechowiak
Collaborator

@jmarshallnz
here's pack of fixes for regressions I've introduced (first 3 commits), including one we were discussing + additional "improvment" for multiimage to avoid loading directory 2 times on alloc: https://github.com/pieh/xbmc/compare/empty_image_fix

push them or they need more work?

jmarshallnz
Tristan Fischer

This causes issue #13351 (http://trac.xbmc.org/ticket/13351).
In short: "Choose a Scraper" and "Current Scraper" are empty on second enter of CGUIDialogContentSettings:
On first init m_scrapers are being filled, on deinit they are cleared and on second open they are not beeing re-filled.

I would fix that with an PR but I don't know what is the desired way ;-)

Trent Nelson
Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 21 unique commits by 1 author.

Sep 08, 2012
Michal Piechowiak allow include resolver to store checked include conditions and their …
…values into map<conditionID:int, value:bool>

store conditions and values used to resolve includes in CGUIWindow
added CGUIInfoManager::ConditionsChangedValues method
fb6a3f0
Michal Piechowiak change bool m_loadOnDemand to LOAD_TYPE m_loadType 5671a6a
Michal Piechowiak allow not to free memory (destroy controls objects) when exiting window
added additional checks in AllocResources - we have to load .xml file if:
 - load type is set to LOAD_EVERY_TIME (all windows use it by default)
 - window is loaded and any of include condition have changed value
 - window isn't loaded

we have to unload window before loading if window wasn't unloaded before and include conditions have change value(s)
afffab0
Michal Piechowiak store and reuse window xml root node
this allows to avoid reading and parsing xml file in windows we already used before and are loaded on demand or their include conditions have changed values
996bd17
Michal Piechowiak regression fix: override SetInitialVisibility() in CGUIBaseContainer …
…to force restoring static items before restoring control states ( in CGUIWindow::OnInitWindow, SetInitialVisibility() is called before RestoreControlStates() )

not need to call UpdateStaticItems() if we are loading static items from .xml as we do it before SetInitialVisibility is called and it will be called there
f2e9d06
Michal Piechowiak adjust GUIDialogContextMenu: cleaning up initialization/deinitializat…
…ion of dialog

- we need additional members to remember window coordinates (these are fetched while loading window .xml file and later are changed when setting position of ContextMenu) and size of background image
- we don't need to call SetInitialVisibility - it's alreadu done in CGUIWindow::OnWindowInit
- we need to manually remove choice buttons in OnDeinitWindow
- we need to store size of background image to properly set its size it in consequent showings
e30dbc2
Michal Piechowiak keep these windows in memory, they're ready as-is 4ce5d78
Michal Piechowiak adjust GUIDialogBoxBase: store heading,lines,choices and set them whe…
…n initing window and if dialog is already active
158c99b
Michal Piechowiak adjust GUISlideShow: move stoping background loader to window deinit 53eabbf
Michal Piechowiak adjust GUIDialogMediaSource: clear list with paths on deinit bb3a2bc
Michal Piechowiak adjust GUIDialogSelect: don't reset GUIViewControl when leaving windo…
…w, clear it

reset it when we unload window
b5843d8
Michal Piechowiak adjust GUIDialogNetworkSetup: change control types only when we load …
…window, fill/clear protocol spinner when we init/deinit window
d260bfb
Michal Piechowiak adjust GUIDialogPeripheralManager: we would run OnInitWindow twice du…
…e to not consuming GUI_MSG_WINDOW_INIT message

also move init actions to OnInitWindow callback
4e00b80
Michal Piechowiak adjust GUIDialogVideoScan: hide progress controls if not used 83a3f44
Michal Piechowiak adjust GUIDialogSlider: nullify callbacks on window deinit 5eadd51
Michal Piechowiak adjust GUIWindowFullscreen: don't toggle DynamicResourceAlloc, shuffl…
…e deinit order a little and let generic window code to handle control unloading/freeing
32fdcd9
Michal Piechowiak adjust GUIDialogTextViewer: reset textarea and heading controls after…
… deinit
aa037df
Michal Piechowiak adjust GUIDialogSmartPlaylistEditor: move playlist type specific conf…
…iguration to OnInitWindow
00bd5fb
Michal Piechowiak adjust GUIDialogSmartPlaylistRule: clear rule spinner before filling …
…it, clear rule and operand spinner on deinit and try to change value button to edit control just once on window load
5649658
Michal Piechowiak adjust GUIWindowSystemInfo: clear labels on window deinit d11b741
Michal Piechowiak log: add window loadType to debug log on window load 7614940
This page is out of date. Refresh to see the latest.

Showing 85 changed files with 464 additions and 172 deletions. Show diff stats Hide diff stats

  1. 1  xbmc/Application.cpp
  2. 10  xbmc/GUIInfoManager.cpp
  3. 3  xbmc/GUIInfoManager.h
  4. 3  xbmc/addons/AddonCallbacksGUI.cpp
  5. 1  xbmc/addons/GUIDialogAddonInfo.cpp
  6. 7  xbmc/addons/Skin.cpp
  7. 2  xbmc/addons/Skin.h
  8. 75  xbmc/dialogs/GUIDialogBoxBase.cpp
  9. 12  xbmc/dialogs/GUIDialogBoxBase.h
  10. 2  xbmc/dialogs/GUIDialogBusy.cpp
  11. 1  xbmc/dialogs/GUIDialogButtonMenu.cpp
  12. 44  xbmc/dialogs/GUIDialogContextMenu.cpp
  13. 5  xbmc/dialogs/GUIDialogContextMenu.h
  14. 2  xbmc/dialogs/GUIDialogExtendedProgressBar.cpp
  15. 1  xbmc/dialogs/GUIDialogFavourites.cpp
  16. 1  xbmc/dialogs/GUIDialogFileBrowser.cpp
  17. 2  xbmc/dialogs/GUIDialogKaiToast.cpp
  18. 1  xbmc/dialogs/GUIDialogKeyboardGeneric.cpp
  19. 10  xbmc/dialogs/GUIDialogMediaSource.cpp
  20. 1  xbmc/dialogs/GUIDialogMediaSource.h
  21. 2  xbmc/dialogs/GUIDialogMuteBug.cpp
  22. 1  xbmc/dialogs/GUIDialogNumeric.cpp
  23. 7  xbmc/dialogs/GUIDialogOK.cpp
  24. 2  xbmc/dialogs/GUIDialogOK.h
  25. 1  xbmc/dialogs/GUIDialogPlayerControls.cpp
  26. 14  xbmc/dialogs/GUIDialogProgress.cpp
  27. 5  xbmc/dialogs/GUIDialogProgress.h
  28. 2  xbmc/dialogs/GUIDialogSeekBar.cpp
  29. 9  xbmc/dialogs/GUIDialogSelect.cpp
  30. 1  xbmc/dialogs/GUIDialogSelect.h
  31. 5  xbmc/dialogs/GUIDialogSlider.cpp
  32. 33  xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
  33. 2  xbmc/dialogs/GUIDialogSmartPlaylistEditor.h
  34. 20  xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
  35. 2  xbmc/dialogs/GUIDialogSmartPlaylistRule.h
  36. 15  xbmc/dialogs/GUIDialogTextViewer.cpp
  37. 2  xbmc/dialogs/GUIDialogTextViewer.h
  38. 2  xbmc/dialogs/GUIDialogVolumeBar.cpp
  39. 23  xbmc/dialogs/GUIDialogYesNo.cpp
  40. 2  xbmc/dialogs/GUIDialogYesNo.h
  41. 13  xbmc/guilib/GUIBaseContainer.cpp
  42. 3  xbmc/guilib/GUIBaseContainer.h
  43. 16  xbmc/guilib/GUIIncludes.cpp
  44. 4  xbmc/guilib/GUIIncludes.h
  45. 14  xbmc/guilib/GUIMessage.h
  46. 97  xbmc/guilib/GUIWindow.cpp
  47. 13  xbmc/guilib/GUIWindow.h
  48. 5  xbmc/guilib/GUIWindowManager.cpp
  49. 2  xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp
  50. 2  xbmc/interfaces/python/xbmcmodule/GUIPythonWindowDialog.cpp
  51. 4  xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
  52. 2  xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXMLDialog.cpp
  53. 1  xbmc/music/dialogs/GUIDialogMusicInfo.cpp
  54. 1  xbmc/music/dialogs/GUIDialogMusicOSD.cpp
  55. 1  xbmc/music/dialogs/GUIDialogMusicOverlay.cpp
  56. 1  xbmc/music/dialogs/GUIDialogMusicScan.cpp
  57. 1  xbmc/music/dialogs/GUIDialogSongInfo.cpp
  58. 1  xbmc/music/dialogs/GUIDialogVisualisationPresetList.cpp
  59. 1  xbmc/music/windows/GUIWindowVisualisation.cpp
  60. 18  xbmc/network/GUIDialogNetworkSetup.cpp
  61. 2  xbmc/network/GUIDialogNetworkSetup.h
  62. 12  xbmc/peripherals/dialogs/GUIDialogPeripheralManager.cpp
  63. 2  xbmc/peripherals/dialogs/GUIDialogPeripheralManager.h
  64. 1  xbmc/pictures/GUIDialogPictureInfo.cpp
  65. 37  xbmc/pictures/GUIWindowSlideShow.cpp
  66. 2  xbmc/pictures/GUIWindowSlideShow.h
  67. 1  xbmc/settings/GUIDialogSettings.cpp
  68. 1  xbmc/settings/GUIWindowSettings.cpp
  69. 1  xbmc/settings/GUIWindowSettingsCategory.cpp
  70. 1  xbmc/settings/GUIWindowSettingsProfile.cpp
  71. 1  xbmc/video/dialogs/GUIDialogFullScreenInfo.cpp
  72. 1  xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
  73. 1  xbmc/video/dialogs/GUIDialogVideoInfo.cpp
  74. 1  xbmc/video/dialogs/GUIDialogVideoOSD.cpp
  75. 1  xbmc/video/dialogs/GUIDialogVideoOverlay.cpp
  76. 6  xbmc/video/dialogs/GUIDialogVideoScan.cpp
  77. 20  xbmc/video/windows/GUIWindowFullScreen.cpp
  78. 2  xbmc/video/windows/GUIWindowFullScreen.h
  79. 1  xbmc/windows/GUIMediaWindow.cpp
  80. 1  xbmc/windows/GUIWindowFileManager.cpp
  81. 1  xbmc/windows/GUIWindowHome.cpp
  82. 1  xbmc/windows/GUIWindowLoginScreen.cpp
  83. 2  xbmc/windows/GUIWindowPointer.cpp
  84. 2  xbmc/windows/GUIWindowSystemInfo.cpp
  85. 1  xbmc/windows/GUIWindowWeather.cpp
1  xbmc/Application.cpp
@@ -2185,6 +2185,7 @@ bool CApplication::LoadUserWindows()
2185 2185
             continue;
2186 2186
           }
2187 2187
           pWindow->SetVisibleCondition(visibleCondition);
  2188
+          pWindow->SetLoadType(CGUIWindow::KEEP_IN_MEMORY);
2188 2189
           g_windowManager.AddCustomWindow(pWindow);
2189 2190
         }
2190 2191
       }
10  xbmc/GUIInfoManager.cpp
@@ -5271,3 +5271,13 @@ CStdString CGUIInfoManager::GetSkinVariableString(int info,
5271 5271
 
5272 5272
   return "";
5273 5273
 }
  5274
+
  5275
+bool CGUIInfoManager::ConditionsChangedValues(const std::map<int, bool>& map)
  5276
+{
  5277
+  for (std::map<int, bool>::const_iterator it = map.begin() ; it != map.end() ; it++)
  5278
+  {
  5279
+    if (GetBoolValue(it->first) != it->second)
  5280
+      return true;
  5281
+  }
  5282
+  return false;
  5283
+}
3  xbmc/GUIInfoManager.h
@@ -801,6 +801,9 @@ class CGUIInfoManager : public IMsgTargetCallback, public Observable
801 801
   int RegisterSkinVariableString(const INFO::CSkinVariableString* info);
802 802
   int TranslateSkinVariableString(const CStdString& name, int context);
803 803
   CStdString GetSkinVariableString(int info, bool preferImage = false, const CGUIListItem *item=NULL);
  804
+
  805
+  /// \brief iterates through boolean conditions and compares their stored values to current values. Returns true if any condition changed value.
  806
+  bool ConditionsChangedValues(const std::map<int, bool>& map);
804 807
 protected:
805 808
   friend class INFO::InfoSingle;
806 809
   bool GetBool(int condition, int contextWindow = 0, const CGUIListItem *item=NULL);
3  xbmc/addons/AddonCallbacksGUI.cpp
@@ -1234,7 +1234,7 @@ CGUIAddonWindow::CGUIAddonWindow(int id, CStdString strXML, CAddon* addon)
1234 1234
  , m_actionEvent(true)
1235 1235
  , m_addon(addon)
1236 1236
 {
1237  
-  m_loadOnDemand  = false;
  1237
+  m_loadType = LOAD_ON_GUI_INIT;
1238 1238
   CBOnInit        = NULL;
1239 1239
   CBOnFocus       = NULL;
1240 1240
   CBOnClick       = NULL;
@@ -1482,7 +1482,6 @@ CGUIAddonWindowDialog::CGUIAddonWindowDialog(int id, CStdString strXML, CAddon*
1482 1482
 : CGUIAddonWindow(id,strXML,addon)
1483 1483
 {
1484 1484
   m_bRunning = false;
1485  
-  m_loadOnDemand = false;
1486 1485
   m_bIsDialog = true;
1487 1486
 }
1488 1487
 
1  xbmc/addons/GUIDialogAddonInfo.cpp
@@ -54,6 +54,7 @@ CGUIDialogAddonInfo::CGUIDialogAddonInfo(void)
54 54
     : CGUIDialog(WINDOW_DIALOG_ADDON_INFO, "DialogAddonInfo.xml")
55 55
 {
56 56
   m_item = CFileItemPtr(new CFileItem);
  57
+  m_loadType = KEEP_IN_MEMORY;
57 58
 }
58 59
 
59 60
 CGUIDialogAddonInfo::~CGUIDialogAddonInfo(void)
7  xbmc/addons/Skin.cpp
@@ -180,9 +180,12 @@ void CSkinInfo::LoadIncludes()
180 180
   m_includes.LoadIncludes(includesPath);
181 181
 }
182 182
 
183  
-void CSkinInfo::ResolveIncludes(TiXmlElement *node)
  183
+void CSkinInfo::ResolveIncludes(TiXmlElement *node, std::map<int, bool>* xmlIncludeConditions /* = NULL */)
184 184
 {
185  
-  m_includes.ResolveIncludes(node);
  185
+  if(xmlIncludeConditions)
  186
+    xmlIncludeConditions->clear();
  187
+
  188
+  m_includes.ResolveIncludes(node, xmlIncludeConditions);
186 189
 }
187 190
 
188 191
 int CSkinInfo::GetStartWindow() const
2  xbmc/addons/Skin.h
@@ -92,7 +92,7 @@ class CSkinInfo : public CAddon
92 92
    */
93 93
   static bool TranslateResolution(const CStdString &name, RESOLUTION_INFO &res);
94 94
 
95  
-  void ResolveIncludes(TiXmlElement *node);
  95
+  void ResolveIncludes(TiXmlElement *node, std::map<int, bool>* xmlIncludeConditions = NULL);
96 96
 
97 97
   float GetEffectsSlowdown() const { return m_effectsSlowDown; };
98 98
 
75  xbmc/dialogs/GUIDialogBoxBase.cpp
@@ -26,10 +26,15 @@
26 26
 
27 27
 using namespace std;
28 28
 
  29
+#define CONTROL_HEADING 1
  30
+#define CONTROL_LINES_START 2
  31
+#define CONTROL_CHOICES_START 10
  32
+
29 33
 CGUIDialogBoxBase::CGUIDialogBoxBase(int id, const CStdString &xmlFile)
30 34
     : CGUIDialog(id, xmlFile)
31 35
 {
32 36
   m_bConfirmed = false;
  37
+  m_loadType = KEEP_IN_MEMORY;
33 38
 }
34 39
 
35 40
 CGUIDialogBoxBase::~CGUIDialogBoxBase(void)
@@ -58,47 +63,58 @@ bool CGUIDialogBoxBase::IsConfirmed() const
58 63
 
59 64
 void CGUIDialogBoxBase::SetHeading(const CVariant& heading)
60 65
 {
61  
-  Initialize();
62  
-  CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), 1);
63  
-  msg.SetLabel(GetLocalized(heading));
64  
-
65  
-  if(g_application.IsCurrentThread())
66  
-    OnMessage(msg);
67  
-  else
68  
-    g_windowManager.SendThreadMessage(msg, GetID());
  66
+  m_strHeading = GetLocalized(heading);
  67
+  if (IsActive())
  68
+    SET_CONTROL_LABEL_THREAD_SAFE(1, m_strHeading);
69 69
 }
70 70
 
71 71
 void CGUIDialogBoxBase::SetLine(int iLine, const CVariant& line)
72 72
 {
73  
-  Initialize();
74  
-  CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), iLine + 2);
75  
-  msg.SetLabel(GetLocalized(line));
76  
-
77  
-  if(g_application.IsCurrentThread())
78  
-    OnMessage(msg);
79  
-  else
80  
-    g_windowManager.SendThreadMessage(msg, GetID());
  73
+  if (iLine < 0 || iLine >= DIALOG_MAX_LINES)
  74
+    return;
  75
+
  76
+  m_strLines[iLine] = GetLocalized(line);
  77
+  if (IsActive())
  78
+    SET_CONTROL_LABEL_THREAD_SAFE(CONTROL_LINES_START + iLine, m_strLines[iLine]);
81 79
 }
82 80
 
83 81
 void CGUIDialogBoxBase::SetChoice(int iButton, const CVariant &choice) // iButton == 0 for no, 1 for yes
84 82
 {
85  
-  Initialize();
86  
-  CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), 10+iButton);
87  
-  msg.SetLabel(GetLocalized(choice));
88  
-
89  
-  if(g_application.IsCurrentThread())
90  
-    OnMessage(msg);
91  
-  else
92  
-    g_windowManager.SendThreadMessage(msg, GetID());
  83
+  if (iButton < 0 || iButton >= DIALOG_MAX_CHOICES)
  84
+    return;
  85
+
  86
+  m_strChoices[iButton] = GetLocalized(choice);
  87
+  if (IsActive())
  88
+    SET_CONTROL_LABEL_THREAD_SAFE(CONTROL_CHOICES_START + iButton, m_strChoices[iButton]);
93 89
 }
94 90
 
95 91
 void CGUIDialogBoxBase::OnInitWindow()
96 92
 {
97 93
   // set focus to default
98 94
   m_lastControlID = m_defaultControl;
  95
+
  96
+  // set control labels
  97
+  SET_CONTROL_LABEL(CONTROL_HEADING, m_strHeading);
  98
+  for (int i = 0 ; i < DIALOG_MAX_LINES ; ++i)
  99
+    SET_CONTROL_LABEL(CONTROL_LINES_START + i, m_strLines[i]);
  100
+  for (int i = 0 ; i < DIALOG_MAX_CHOICES ; ++i)
  101
+    SET_CONTROL_LABEL(CONTROL_CHOICES_START + i, m_strChoices[i]);
  102
+
99 103
   CGUIDialog::OnInitWindow();
100 104
 }
101 105
 
  106
+void CGUIDialogBoxBase::OnDeinitWindow(int nextWindowID)
  107
+{
  108
+  // make sure we set default labels for heading, lines and choices
  109
+  SetHeading(GetDefaultLabel(CONTROL_HEADING));
  110
+  for (int i = 0 ; i < DIALOG_MAX_LINES ; ++i)
  111
+    SetLine(i, GetDefaultLabel(CONTROL_LINES_START + i));
  112
+  for (int i = 0 ; i < DIALOG_MAX_CHOICES ; ++i)
  113
+    SetChoice(i, GetDefaultLabel(CONTROL_CHOICES_START + i));
  114
+
  115
+  CGUIDialog::OnDeinitWindow(nextWindowID);
  116
+}
  117
+
102 118
 CStdString CGUIDialogBoxBase::GetLocalized(const CVariant &var) const
103 119
 {
104 120
   if (var.isString())
@@ -107,3 +123,14 @@ CStdString CGUIDialogBoxBase::GetLocalized(const CVariant &var) const
107 123
     return g_localizeStrings.Get((uint32_t)var.asInteger());
108 124
   return "";
109 125
 }
  126
+
  127
+CStdString CGUIDialogBoxBase::GetDefaultLabel(int controlId) const
  128
+{
  129
+  int labelId = GetDefaultLabelID(controlId);
  130
+  return labelId != -1 ? g_localizeStrings.Get(labelId) : "";
  131
+}
  132
+
  133
+int CGUIDialogBoxBase::GetDefaultLabelID(int controlId) const
  134
+{
  135
+  return -1;
  136
+}
12  xbmc/dialogs/GUIDialogBoxBase.h
@@ -24,6 +24,9 @@
24 24
 #include "guilib/GUIDialog.h"
25 25
 #include "utils/Variant.h"
26 26
 
  27
+#define DIALOG_MAX_LINES 3
  28
+#define DIALOG_MAX_CHOICES 2
  29
+
27 30
 class CGUIDialogBoxBase :
28 31
       public CGUIDialog
29 32
 {
@@ -36,6 +39,8 @@ class CGUIDialogBoxBase :
36 39
   void SetHeading(const CVariant &heading);
37 40
   void SetChoice(int iButton, const CVariant &choice);
38 41
 protected:
  42
+  CStdString GetDefaultLabel(int controlId) const;
  43
+  virtual int GetDefaultLabelID(int controlId) const;
39 44
   /*! \brief Get a localized string from a variant
40 45
    If the varaint is already a string we return directly, else if it's an integer we return the corresponding
41 46
    localized string.
@@ -44,5 +49,12 @@ class CGUIDialogBoxBase :
44 49
   CStdString GetLocalized(const CVariant &var) const;
45 50
 
46 51
   virtual void OnInitWindow();
  52
+  virtual void OnDeinitWindow(int nextWindowID);
  53
+
47 54
   bool m_bConfirmed;
  55
+
  56
+  // actual strings
  57
+  std::string m_strHeading;
  58
+  std::string m_strLines[DIALOG_MAX_LINES];
  59
+  std::string m_strChoices[DIALOG_MAX_CHOICES];
48 60
 };
2  xbmc/dialogs/GUIDialogBusy.cpp
@@ -25,7 +25,7 @@
25 25
 CGUIDialogBusy::CGUIDialogBusy(void)
26 26
   : CGUIDialog(WINDOW_DIALOG_BUSY, "DialogBusy.xml"), m_bLastVisible(false)
27 27
 {
28  
-  m_loadOnDemand = false;
  28
+  m_loadType = LOAD_ON_GUI_INIT;
29 29
   m_bModal = true;
30 30
 }
31 31
 
1  xbmc/dialogs/GUIDialogButtonMenu.cpp
@@ -29,6 +29,7 @@
29 29
 CGUIDialogButtonMenu::CGUIDialogButtonMenu(int id, const CStdString &xmlFile)
30 30
 : CGUIDialog(id, xmlFile)
31 31
 {
  32
+  m_loadType = KEEP_IN_MEMORY;
32 33
 }
33 34
 
34 35
 CGUIDialogButtonMenu::~CGUIDialogButtonMenu(void)
44  xbmc/dialogs/GUIDialogContextMenu.cpp
@@ -71,9 +71,12 @@ void CContextButtons::Add(unsigned int button, int label)
71 71
   push_back(pair<unsigned int, CStdString>(button, g_localizeStrings.Get(label)));
72 72
 }
73 73
 
74  
-CGUIDialogContextMenu::CGUIDialogContextMenu(void):CGUIDialog(WINDOW_DIALOG_CONTEXT_MENU, "DialogContextMenu.xml")
  74
+CGUIDialogContextMenu::CGUIDialogContextMenu(void)
  75
+  : CGUIDialog(WINDOW_DIALOG_CONTEXT_MENU, "DialogContextMenu.xml")
75 76
 {
76 77
   m_clickedButton = -1;
  78
+  m_backgroundImageSize = 0;
  79
+  m_loadType = KEEP_IN_MEMORY;
77 80
 }
78 81
 
79 82
 CGUIDialogContextMenu::~CGUIDialogContextMenu(void)
@@ -184,12 +187,12 @@ void CGUIDialogContextMenu::SetupButtons()
184 187
       if (pGroupList->GetOrientation() == VERTICAL)
185 188
       {
186 189
         // keep gap between bottom edges of grouplist and background image
187  
-        pControl->SetHeight(pControl->GetHeight() - pGroupList->Size() + pGroupList->GetHeight());
  190
+        pControl->SetHeight(m_backgroundImageSize - pGroupList->Size() + pGroupList->GetHeight());
188 191
       }
189 192
       else
190 193
       {
191 194
         // keep gap between right edges of grouplist and background image
192  
-        pControl->SetWidth(pControl->GetWidth() - pGroupList->Size() + pGroupList->GetWidth());
  195
+        pControl->SetWidth(m_backgroundImageSize - pGroupList->Size() + pGroupList->GetWidth());
193 196
       }
194 197
     }
195 198
 #if PRE_SKIN_VERSION_11_COMPATIBILITY
@@ -671,15 +674,39 @@ CMediaSource *CGUIDialogContextMenu::GetShare(const CStdString &type, const CFil
671 674
 
672 675
 void CGUIDialogContextMenu::OnWindowLoaded()
673 676
 {
  677
+  m_coordX = m_posX;
  678
+  m_coordY = m_posY;
  679
+  
  680
+  const CGUIControlGroupList* pGroupList = NULL;
  681
+  const CGUIControl* pControl = GetControl(GROUP_LIST);
  682
+  if (pControl && pControl->GetControlType() == GUICONTROL_GROUPLIST)
  683
+    pGroupList = (CGUIControlGroupList*)pControl;
  684
+
  685
+  pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE);
  686
+  if (pControl && pGroupList)
  687
+  {
  688
+    if (pGroupList->GetOrientation() == VERTICAL)
  689
+      m_backgroundImageSize = pControl->GetHeight();
  690
+    else
  691
+      m_backgroundImageSize = pControl->GetWidth();
  692
+  }
  693
+
674 694
   CGUIDialog::OnWindowLoaded();
675  
-  SetInitialVisibility();
676  
-  SetupButtons();
677 695
 }
678 696
 
679  
-void CGUIDialogContextMenu::OnWindowUnload()
  697
+void CGUIDialogContextMenu::OnDeinitWindow(int nextWindowID)
680 698
 {
  699
+  //we can't be sure that controls are removed on window unload
  700
+  //we have to remove them to be sure that they won't stay for next use of context menu
  701
+  for (unsigned int i = 0; i < m_buttons.size(); i++)
  702
+  {
  703
+    const CGUIControl *control = GetControl(BUTTON_START + i);
  704
+    if (control)
  705
+      RemoveControl(control);
  706
+  }
  707
+
681 708
   m_buttons.clear();
682  
-  CGUIDialog::OnWindowUnload();
  709
+  CGUIDialog::OnDeinitWindow(nextWindowID);
683 710
 }
684 711
 
685 712
 CStdString CGUIDialogContextMenu::GetDefaultShareNameByType(const CStdString &strType)
@@ -746,6 +773,7 @@ int CGUIDialogContextMenu::ShowAndGetChoice(const CContextButtons &choices)
746 773
   {
747 774
     pMenu->m_buttons = choices;
748 775
     pMenu->Initialize();
  776
+    pMenu->SetupButtons();
749 777
     pMenu->PositionAtCurrentFocus();
750 778
     pMenu->DoModal();
751 779
     return pMenu->m_clickedButton;
@@ -763,7 +791,7 @@ void CGUIDialogContextMenu::PositionAtCurrentFocus()
763 791
     {
764 792
       CPoint pos = focusedControl->GetRenderPosition() + CPoint(focusedControl->GetWidth() * 0.5f, focusedControl->GetHeight() * 0.5f)
765 793
                    + window->GetRenderPosition();
766  
-      SetPosition(m_posX + pos.x - GetWidth() * 0.5f, m_posY + pos.y - GetHeight() * 0.5f);
  794
+      SetPosition(m_coordX + pos.x - GetWidth() * 0.5f, m_coordY + pos.y - GetHeight() * 0.5f);
767 795
       return;
768 796
     }
769 797
   }
5  xbmc/dialogs/GUIDialogContextMenu.h
@@ -179,13 +179,16 @@ class CGUIDialogContextMenu :
179 179
   virtual float GetHeight() const;
180 180
   virtual void OnInitWindow();
181 181
   virtual void OnWindowLoaded();
182  
-  virtual void OnWindowUnload();
  182
+  virtual void OnDeinitWindow(int nextWindowID);
183 183
   static CStdString GetDefaultShareNameByType(const CStdString &strType);
184 184
   static void SetDefault(const CStdString &strType, const CStdString &strDefault);
185 185
   static void ClearDefault(const CStdString &strType);
186 186
   static CMediaSource *GetShare(const CStdString &type, const CFileItem *item);
187 187
 
188 188
 private:
  189
+  float m_coordX, m_coordY;
  190
+  /// \brief Stored size of background image (height or width depending on grouplist orientation)
  191
+  float m_backgroundImageSize;
189 192
   int m_clickedButton;
190 193
   CContextButtons m_buttons;
191 194
 };
2  xbmc/dialogs/GUIDialogExtendedProgressBar.cpp
@@ -58,7 +58,7 @@ void CGUIDialogProgressBarHandle::SetProgress(int currentItem, int itemCount)
58 58
 CGUIDialogExtendedProgressBar::CGUIDialogExtendedProgressBar(void)
59 59
   : CGUIDialog(WINDOW_DIALOG_EXT_PROGRESS, "DialogExtendedProgressBar.xml")
60 60
 {
61  
-  m_loadOnDemand    = false;
  61
+  m_loadType        = LOAD_ON_GUI_INIT;
62 62
   m_iLastSwitchTime = 0;
63 63
   m_iCurrentItem    = 0;
64 64
 }
1  xbmc/dialogs/GUIDialogFavourites.cpp
@@ -39,6 +39,7 @@ CGUIDialogFavourites::CGUIDialogFavourites(void)
39 39
     : CGUIDialog(WINDOW_DIALOG_FAVOURITES, "DialogFavourites.xml")
40 40
 {
41 41
   m_favourites = new CFileItemList;
  42
+  m_loadType = KEEP_IN_MEMORY;
42 43
 }
43 44
 
44 45
 CGUIDialogFavourites::~CGUIDialogFavourites(void)
1  xbmc/dialogs/GUIDialogFileBrowser.cpp
@@ -72,6 +72,7 @@ CGUIDialogFileBrowser::CGUIDialogFileBrowser()
72 72
   m_thumbLoader.SetObserver(this);
73 73
   m_flipEnabled = false;
74 74
   m_multipleSelection = false;
  75
+  m_loadType = KEEP_IN_MEMORY;
75 76
 }
76 77
 
77 78
 CGUIDialogFileBrowser::~CGUIDialogFileBrowser()
2  xbmc/dialogs/GUIDialogKaiToast.cpp
@@ -37,7 +37,7 @@ CGUIDialogKaiToast::CGUIDialogKaiToast(void)
37 37
 : CGUIDialog(WINDOW_DIALOG_KAI_TOAST, "DialogKaiToast.xml")
38 38
 {
39 39
   m_defaultIcon = "";
40  
-  m_loadOnDemand = false;
  40
+  m_loadType = LOAD_ON_GUI_INIT;
41 41
   m_timer = 0;
42 42
   m_toastDisplayTime = 0;
43 43
   m_toastMessageTime = 0;
1  xbmc/dialogs/GUIDialogKeyboardGeneric.cpp
@@ -68,6 +68,7 @@ CGUIDialogKeyboardGeneric::CGUIDialogKeyboardGeneric()
68 68
   m_keyType = LOWER;
69 69
   m_strHeading = "";
70 70
   m_lastRemoteClickTime = 0;
  71
+  m_loadType = KEEP_IN_MEMORY;
71 72
 }
72 73
 
73 74
 void CGUIDialogKeyboardGeneric::OnInitWindow()
10  xbmc/dialogs/GUIDialogMediaSource.cpp
@@ -60,6 +60,7 @@ CGUIDialogMediaSource::CGUIDialogMediaSource(void)
60 60
     : CGUIDialog(WINDOW_DIALOG_MEDIA_SOURCE, "DialogMediaSource.xml")
61 61
 {
62 62
   m_paths =  new CFileItemList;
  63
+  m_loadType = KEEP_IN_MEMORY;
63 64
 }
64 65
 
65 66
 CGUIDialogMediaSource::~CGUIDialogMediaSource()
@@ -548,3 +549,12 @@ vector<CStdString> CGUIDialogMediaSource::GetPaths()
548 549
   }
549 550
   return paths;
550 551
 }
  552
+
  553
+void CGUIDialogMediaSource::OnDeinitWindow(int nextWindowID)
  554
+{
  555
+  CGUIDialog::OnDeinitWindow(nextWindowID);
  556
+
  557
+  // clear paths container
  558
+  CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PATH, 0);
  559
+  OnMessage(msg);
  560
+}
1  xbmc/dialogs/GUIDialogMediaSource.h
@@ -33,6 +33,7 @@ class CGUIDialogMediaSource :
33 33
   CGUIDialogMediaSource(void);
34 34
   virtual ~CGUIDialogMediaSource(void);
35 35
   virtual bool OnMessage(CGUIMessage& message);
  36
+  virtual void OnDeinitWindow(int nextWindowID);
36 37
   virtual bool OnBack(int actionID);
37 38
   virtual void OnWindowLoaded();
38 39
   static bool ShowAndAddMediaSource(const CStdString &type);
2  xbmc/dialogs/GUIDialogMuteBug.cpp
@@ -28,7 +28,7 @@
28 28
 CGUIDialogMuteBug::CGUIDialogMuteBug(void)
29 29
     : CGUIDialog(WINDOW_DIALOG_MUTE_BUG, "DialogMuteBug.xml")
30 30
 {
31  
-  m_loadOnDemand = false;
  31
+  m_loadType = LOAD_ON_GUI_INIT;
32 32
 }
33 33
 
34 34
 CGUIDialogMuteBug::~CGUIDialogMuteBug(void)
1  xbmc/dialogs/GUIDialogNumeric.cpp
@@ -49,6 +49,7 @@ CGUIDialogNumeric::CGUIDialogNumeric(void)
49 49
   m_block = 0;
50 50
   memset(&m_datetime, 0, sizeof(SYSTEMTIME));
51 51
   m_dirty = false;
  52
+  m_loadType = KEEP_IN_MEMORY;
52 53
 }
53 54
 
54 55
 CGUIDialogNumeric::~CGUIDialogNumeric(void)
7  xbmc/dialogs/GUIDialogOK.cpp
@@ -59,3 +59,10 @@ void CGUIDialogOK::ShowAndGetInput(const CVariant &heading, const CVariant &line
59 59
   dialog->SetLine(2, line2);
60 60
   dialog->DoModal();
61 61
 }
  62
+
  63
+int CGUIDialogOK::GetDefaultLabelID(int controlId) const
  64
+{
  65
+  if (controlId == ID_BUTTON_OK)
  66
+    return 186;
  67
+  return CGUIDialogBoxBase::GetDefaultLabelID(controlId);
  68
+}
2  xbmc/dialogs/GUIDialogOK.h
@@ -31,4 +31,6 @@ class CGUIDialogOK :
31 31
   virtual ~CGUIDialogOK(void);
32 32
   virtual bool OnMessage(CGUIMessage& message);
33 33
   static void ShowAndGetInput(const CVariant &heading, const CVariant &line0, const CVariant &line1, const CVariant &line2);
  34
+protected:
  35
+  virtual int GetDefaultLabelID(int controlId) const;
34 36
 };
1  xbmc/dialogs/GUIDialogPlayerControls.cpp
@@ -25,6 +25,7 @@
25 25
 CGUIDialogPlayerControls::CGUIDialogPlayerControls(void)
26 26
     : CGUIDialog(WINDOW_DIALOG_PLAYER_CONTROLS, "PlayerControls.xml")
27 27
 {
  28
+  m_loadType = KEEP_IN_MEMORY;
28 29
 }
29 30
 
30 31
 CGUIDialogPlayerControls::~CGUIDialogPlayerControls(void)
14  xbmc/dialogs/GUIDialogProgress.cpp
@@ -199,15 +199,9 @@ void CGUIDialogProgress::ShowProgressBar(bool bOnOff)
199 199
     g_windowManager.SendThreadMessage(msg, GetID());
200 200
 }
201 201
 
202  
-void CGUIDialogProgress::SetHeading(const string& strLine)
  202
+int CGUIDialogProgress::GetDefaultLabelID(int controlId) const
203 203
 {
204  
-  m_strHeading = strLine;
205  
-  CGUIDialogBoxBase::SetHeading(m_strHeading);
  204
+  if (controlId == CONTROL_CANCEL_BUTTON)
  205
+    return 222;
  206
+  return CGUIDialogBoxBase::GetDefaultLabelID(controlId);
206 207
 }
207  
-
208  
-void CGUIDialogProgress::SetHeading(int iString)
209  
-{
210  
-  m_strHeading = g_localizeStrings.Get(iString);
211  
-  CGUIDialogBoxBase::SetHeading(m_strHeading);
212  
-}
213  
-
5  xbmc/dialogs/GUIDialogProgress.h
@@ -41,8 +41,6 @@ class CGUIDialogProgress :
41 41
   void SetPercentage(int iPercentage);
42 42
   int GetPercentage() const { return m_percentage; };
43 43
   void ShowProgressBar(bool bOnOff);
44  
-  void SetHeading(const std::string& strLine);
45  
-  void SetHeading(int iString);             // for convenience to lookup in strings.xml
46 44
 
47 45
   // Implements IProgressCallback
48 46
   virtual void SetProgressMax(int iMax);
@@ -52,9 +50,10 @@ class CGUIDialogProgress :
52 50
   void SetCanCancel(bool bCanCancel);
53 51
 
54 52
 protected:
  53
+  virtual int GetDefaultLabelID(int controlId) const;
  54
+
55 55
   bool m_bCanCancel;
56 56
   bool m_bCanceled;
57  
-  std::string m_strHeading;
58 57
 
59 58
   int  m_iCurrent;
60 59
   int  m_iMax;
2  xbmc/dialogs/GUIDialogSeekBar.cpp
@@ -37,7 +37,7 @@
37 37
 CGUIDialogSeekBar::CGUIDialogSeekBar(void)
38 38
     : CGUIDialog(WINDOW_DIALOG_SEEK_BAR, "DialogSeekBar.xml")
39 39
 {
40  
-  m_loadOnDemand = false;    // the application class handles our resources
  40
+  m_loadType = LOAD_ON_GUI_INIT;    // the application class handles our resources
41 41
 }
42 42
 
43 43
 CGUIDialogSeekBar::~CGUIDialogSeekBar(void)
9  xbmc/dialogs/GUIDialogSelect.cpp
@@ -40,6 +40,7 @@ CGUIDialogSelect::CGUIDialogSelect(void)
40 40
   m_multiSelection = false;
41 41
   m_vecList = m_vecListInternal;
42 42
   m_iSelected = -1;
  43
+  m_loadType = KEEP_IN_MEMORY;
43 44
 }
44 45
 
45 46
 CGUIDialogSelect::~CGUIDialogSelect(void)
@@ -55,7 +56,7 @@ bool CGUIDialogSelect::OnMessage(CGUIMessage& message)
55 56
   case GUI_MSG_WINDOW_DEINIT:
56 57
     {
57 58
       CGUIDialog::OnMessage(message);
58  
-      m_viewControl.Reset();
  59
+      m_viewControl.Clear();
59 60
 
60 61
       m_bButtonEnabled = false;
61 62
       m_useDetails = false;
@@ -337,3 +338,9 @@ void CGUIDialogSelect::OnInitWindow()
337 338
   if (m_iSelected >= 0)
338 339
     m_viewControl.SetSelectedItem(m_iSelected);
339 340
 }
  341
+
  342
+void CGUIDialogSelect::OnWindowUnload()
  343
+{
  344
+  CGUIDialog::OnWindowUnload();
  345
+  m_viewControl.Reset();
  346
+}
1  xbmc/dialogs/GUIDialogSelect.h
@@ -59,6 +59,7 @@ class CGUIDialogSelect :
59 59
   virtual CGUIControl *GetFirstFocusableControl(int id);
60 60
   virtual void OnWindowLoaded();
61 61
   virtual void OnInitWindow();
  62
+  virtual void OnWindowUnload();
62 63
 
63 64
   bool m_bButtonEnabled;
64 65
   bool m_bButtonPressed;
5  xbmc/dialogs/GUIDialogSlider.cpp
@@ -33,6 +33,7 @@ CGUIDialogSlider::CGUIDialogSlider(void)
33 33
 {
34 34
   m_callback = NULL;
35 35
   m_callbackData = NULL;
  36
+  m_loadType = KEEP_IN_MEMORY;
36 37
 }
37 38
 
38 39
 CGUIDialogSlider::~CGUIDialogSlider(void)
@@ -64,6 +65,10 @@ bool CGUIDialogSlider::OnMessage(CGUIMessage& message)
64 65
       }
65 66
     }
66 67
     break;
  68
+  case GUI_MSG_WINDOW_DEINIT:
  69
+    m_callback = NULL;
  70
+    m_callbackData = NULL;
  71
+    break;
67 72
   }
68 73
   return CGUIDialog::OnMessage(message);
69 74
 }
33  xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
@@ -72,6 +72,7 @@ CGUIDialogSmartPlaylistEditor::CGUIDialogSmartPlaylistEditor(void)
72 72
 {
73 73
   m_cancelled = false;
74 74
   m_ruleLabels = new CFileItemList;
  75
+  m_loadType = KEEP_IN_MEMORY;
75 76
 }
76 77
 
77 78
 CGUIDialogSmartPlaylistEditor::~CGUIDialogSmartPlaylistEditor()
@@ -122,21 +123,6 @@ bool CGUIDialogSmartPlaylistEditor::OnMessage(CGUIMessage& message)
122 123
       return true;
123 124
     }
124 125
     break;
125  
-  case GUI_MSG_WINDOW_INIT:
126  
-    {
127  
-      m_cancelled = false;
128  
-      UpdateButtons();
129  
-    }
130  
-    break;
131  
-  case GUI_MSG_WINDOW_DEINIT:
132  
-    {
133  
-      CGUIDialog::OnMessage(message);
134  
-      // clear the rule list
135  
-      CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_RULE_LIST);
136  
-      OnMessage(msg);
137  
-      m_ruleLabels->Clear();
138  
-    }
139  
-    break;
140 126
   case GUI_MSG_FOCUSED:
141 127
     if (message.GetControlId() == CONTROL_RULE_REMOVE ||
142 128
         message.GetControlId() == CONTROL_RULE_EDIT)
@@ -340,6 +326,13 @@ void CGUIDialogSmartPlaylistEditor::OnWindowLoaded()
340 326
     msg.SetLabel(label);
341 327
     OnMessage(msg);
342 328
   }
  329
+}
  330
+
  331
+void CGUIDialogSmartPlaylistEditor::OnInitWindow()
  332
+{
  333
+  m_cancelled = false;
  334
+  UpdateButtons();
  335
+
343 336
   SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_LIMIT, m_playlist.m_limit);
344 337
 
345 338
   vector<PLAYLIST_TYPE> allowedTypes;
@@ -386,6 +379,16 @@ void CGUIDialogSmartPlaylistEditor::OnWindowLoaded()
386 379
 
387 380
   SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_TYPE, type);
388 381
   m_playlist.SetType(ConvertType(type));
  382
+
  383
+  CGUIDialog::OnInitWindow();
  384
+}
  385
+
  386
+void CGUIDialogSmartPlaylistEditor::OnDeinitWindow(int nextWindowID)
  387
+{
  388
+  CGUIDialog::OnDeinitWindow(nextWindowID);
  389
+  CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_RULE_LIST);
  390
+  OnMessage(msg);
  391
+  m_ruleLabels->Clear();
389 392
 }
390 393
 
391 394
 CGUIDialogSmartPlaylistEditor::PLAYLIST_TYPE CGUIDialogSmartPlaylistEditor::ConvertType(const CStdString &type)
2  xbmc/dialogs/GUIDialogSmartPlaylistEditor.h
@@ -37,6 +37,8 @@ class CGUIDialogSmartPlaylistEditor :
37 37
   virtual bool OnMessage(CGUIMessage& message);
38 38
   virtual bool OnBack(int actionID);
39 39
   virtual void OnWindowLoaded();
  40
+  virtual void OnInitWindow();
  41
+  virtual void OnDeinitWindow(int nextWindowID);
40 42
 
41 43
   static bool EditPlaylist(const CStdString &path, const CStdString &type = "");
42 44
   static bool NewPlaylist(const CStdString &type);
20  xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
@@ -45,6 +45,7 @@ CGUIDialogSmartPlaylistRule::CGUIDialogSmartPlaylistRule(void)
45 45
     : CGUIDialog(WINDOW_DIALOG_SMART_PLAYLIST_RULE, "SmartPlaylistRule.xml")
46 46
 {
47 47
   m_cancelled = false;
  48
+  m_loadType = KEEP_IN_MEMORY;
48 49
 }
49 50
 
50 51
 CGUIDialogSmartPlaylistRule::~CGUIDialogSmartPlaylistRule()
@@ -412,10 +413,17 @@ void CGUIDialogSmartPlaylistRule::AddOperatorLabel(CSmartPlaylistRule::SEARCH_OP
412 413
   OnMessage(select);
413 414
 }
414 415
 
415  
-void CGUIDialogSmartPlaylistRule::OnInitWindow()
  416
+void CGUIDialogSmartPlaylistRule::OnWindowLoaded()
416 417
 {
  418
+  CGUIWindow::OnWindowLoaded();
417 419
   ChangeButtonToEdit(CONTROL_VALUE, true); // true for single label
  420
+}
  421
+
  422
+void CGUIDialogSmartPlaylistRule::OnInitWindow()
  423
+{
418 424
   CGUIDialog::OnInitWindow();
  425
+
  426
+  SendMessage(GUI_MSG_LABEL_RESET, CONTROL_FIELD);
419 427
   // add the fields to the field spincontrol
420 428
   vector<Field> fields = CSmartPlaylistRule::GetFields(m_type);
421 429
   for (unsigned int i = 0; i < fields.size(); i++)
@@ -427,6 +435,16 @@ void CGUIDialogSmartPlaylistRule::OnInitWindow()
427 435
   UpdateButtons();
428 436
 }
429 437
 
  438
+void CGUIDialogSmartPlaylistRule::OnDeinitWindow(int nextWindowID)
  439
+{
  440
+  CGUIDialog::OnDeinitWindow(nextWindowID);
  441
+
  442
+  // reset field spincontrolex
  443
+  SendMessage(GUI_MSG_LABEL_RESET, CONTROL_FIELD);
  444
+  // reset operator spincontrolex
  445
+  SendMessage(GUI_MSG_LABEL_RESET, CONTROL_OPERATOR);
  446
+}
  447
+
430 448
 bool CGUIDialogSmartPlaylistRule::EditRule(CSmartPlaylistRule &rule, const CStdString& type)
431 449
 {
432 450
   CGUIDialogSmartPlaylistRule *editor = (CGUIDialogSmartPlaylistRule *)g_windowManager.GetWindow(WINDOW_DIALOG_SMART_PLAYLIST_RULE);
2  xbmc/dialogs/GUIDialogSmartPlaylistRule.h
@@ -33,6 +33,8 @@ class CGUIDialogSmartPlaylistRule :
33 33
   virtual bool OnMessage(CGUIMessage& message);
34 34
   virtual bool OnBack(int actionID);
35 35
   virtual void OnInitWindow();
  36
+  virtual void OnWindowLoaded();
  37
+  virtual void OnDeinitWindow(int nextWindowID);
36 38
 
37 39
   static bool EditRule(CSmartPlaylistRule &rule, const CStdString& type="songs");
38 40
 
15  xbmc/dialogs/GUIDialogTextViewer.cpp
@@ -27,7 +27,9 @@
27 27
 
28 28
 CGUIDialogTextViewer::CGUIDialogTextViewer(void)
29 29
     : CGUIDialog(WINDOW_DIALOG_TEXT_VIEWER, "DialogTextViewer.xml")
30  
-{}
  30
+{
  31
+  m_loadType = KEEP_IN_MEMORY;
  32
+}
31 33
 
32 34
 CGUIDialogTextViewer::~CGUIDialogTextViewer(void)
33 35
 {}
@@ -79,3 +81,14 @@ void CGUIDialogTextViewer::SetHeading()
79 81
   OnMessage(msg);
80 82
 }
81 83
 
  84
+void CGUIDialogTextViewer::OnDeinitWindow(int nextWindowID)
  85
+{
  86
+  CGUIDialog::OnDeinitWindow(nextWindowID);
  87
+
  88
+  // reset text area
  89
+  CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_TEXTAREA);
  90
+  OnMessage(msgReset);
  91
+
  92
+  // reset heading
  93
+  SET_CONTROL_LABEL(CONTROL_HEADING, "");
  94
+}
2  xbmc/dialogs/GUIDialogTextViewer.h
@@ -34,6 +34,8 @@ class CGUIDialogTextViewer :
34 34
   void SetText(const CStdString& strText) { m_strText = strText; }
35 35
   void SetHeading(const CStdString& strHeading) { m_strHeading = strHeading; }
36 36
 protected:
  37
+  virtual void OnDeinitWindow(int nextWindowID);
  38
+
37 39
   CStdString m_strText;
38 40
   CStdString m_strHeading;
39 41
 
2  xbmc/dialogs/GUIDialogVolumeBar.cpp
@@ -27,7 +27,7 @@
27 27
 CGUIDialogVolumeBar::CGUIDialogVolumeBar(void)
28 28
     : CGUIDialog(WINDOW_DIALOG_VOLUME_BAR, "DialogVolumeBar.xml")
29 29
 {
30  
-  m_loadOnDemand = false;
  30
+  m_loadType = LOAD_ON_GUI_INIT;
31 31
   SetAutoClose(VOLUME_BAR_DISPLAY_TIME);
32 32
 }
33 33
 
23  xbmc/dialogs/GUIDialogYesNo.cpp
@@ -22,6 +22,9 @@
22 22
 #include "GUIDialogYesNo.h"
23 23
 #include "guilib/GUIWindowManager.h"
24 24
 
  25
+#define CONTROL_NO_BUTTON 10
  26
+#define CONTROL_YES_BUTTON 11
  27
+
25 28
 CGUIDialogYesNo::CGUIDialogYesNo(int overrideId /* = -1 */)
26 29
     : CGUIDialogBoxBase(overrideId == -1 ? WINDOW_DIALOG_YES_NO : overrideId, "DialogYesNo.xml")
27 30
 {
@@ -42,13 +45,13 @@ bool CGUIDialogYesNo::OnMessage(CGUIMessage& message)
42 45
       int iAction = message.GetParam1();
43 46
       if (1 || ACTION_SELECT_ITEM == iAction)
44 47
       {
45  
-        if (iControl == 10)
  48
+        if (iControl == CONTROL_NO_BUTTON)
46 49
         {
47