From 06d83a9bb07ab4f57dc675df958a3197086b12ad Mon Sep 17 00:00:00 2001 From: Jonathan Marshall Date: Sat, 31 Mar 2012 19:24:19 +1300 Subject: [PATCH] fix dialog autoclose by ensuring the timer starts only once we've rendered once (frametime is then accurate) --- xbmc/guilib/GUIDialog.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/xbmc/guilib/GUIDialog.cpp b/xbmc/guilib/GUIDialog.cpp index 8e9047da05c2a..74c6ad0a4811f 100644 --- a/xbmc/guilib/GUIDialog.cpp +++ b/xbmc/guilib/GUIDialog.cpp @@ -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; } @@ -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; } } @@ -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(); }