Skip to content

Commit

Permalink
fix dialog autoclose by ensuring the timer starts only once we've ren…
Browse files Browse the repository at this point in the history
…dered once (frametime is then accurate)
  • Loading branch information
Jonathan Marshall authored and Memphiz committed Mar 31, 2012
1 parent eb40a8c commit 06d83a9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions xbmc/guilib/GUIDialog.cpp
Expand Up @@ -35,6 +35,8 @@ CGUIDialog::CGUIDialog(int id, const CStdString &xmlFile)
m_wasRunning = false;
m_renderOrder = 1;
m_autoClosing = false;
m_showStartTime = 0;
m_showDuration = 0;
m_enableSound = true;
}

Expand Down Expand Up @@ -97,7 +99,7 @@ bool CGUIDialog::OnMessage(CGUIMessage& message)
case GUI_MSG_WINDOW_INIT:
{
CGUIWindow::OnMessage(message);
m_showStartTime = CTimeUtils::GetFrameTime();
m_showStartTime = 0;
return true;
}
}
Expand Down Expand Up @@ -226,8 +228,19 @@ void CGUIDialog::Show()

void CGUIDialog::FrameMove()
{
if (m_autoClosing && m_showStartTime + m_showDuration < CTimeUtils::GetFrameTime() && !m_closing)
Close();
if (m_autoClosing)
{ // check if our timer is running
if (!m_showStartTime)
{
if (HasRendered()) // start timer
m_showStartTime = CTimeUtils::GetFrameTime();
}
else
{
if (m_showStartTime + m_showDuration < CTimeUtils::GetFrameTime() && !m_closing)
Close();
}
}
CGUIWindow::FrameMove();
}

Expand Down

0 comments on commit 06d83a9

Please sign in to comment.