Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix null ptr dereference of GUIDialogCache. fixes #14065.

  • Loading branch information...
commit e28aed30bbfc0da6972a50a8a8d42c41c9468253 1 parent e008bad
Jonathan Marshall authored
Showing with 42 additions and 22 deletions.
  1. +42 −22 xbmc/dialogs/GUIDialogCache.cpp
View
64 xbmc/dialogs/GUIDialogCache.cpp
@@ -30,16 +30,20 @@
CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const CStdString& strHeader, const CStdString& strMsg) : CThread("CGUIDialogCache")
{
+ m_strHeader = strHeader;
+ m_strLinePrev = strMsg;
+ bSentCancel = false;
+ dwDelay = 0;
+
m_pDlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
+ if (!m_pDlg)
+ return;
+
/* if progress dialog is already running, take it over */
if( m_pDlg->IsDialogRunning() )
dwDelay = 0;
- m_strHeader = strHeader;
- m_strLinePrev = strMsg;
- bSentCancel = false;
-
if(dwDelay == 0)
OpenDialog();
else
@@ -54,7 +58,7 @@ void CGUIDialogCache::Close(bool bForceClose)
// we cannot wait for the app thread to process the close message
// as this might happen during player startup which leads to a deadlock
- if (m_pDlg->IsDialogRunning())
+ if (m_pDlg && m_pDlg->IsDialogRunning())
CApplicationMessenger::Get().Close(m_pDlg,bForceClose,false);
//Set stop, this will kill this object, when thread stops
@@ -63,19 +67,22 @@ void CGUIDialogCache::Close(bool bForceClose)
CGUIDialogCache::~CGUIDialogCache()
{
- if(m_pDlg->IsDialogRunning())
+ if(m_pDlg && m_pDlg->IsDialogRunning())
m_pDlg->Close();
}
void CGUIDialogCache::OpenDialog()
-{
- if (m_strHeader.IsEmpty())
- m_pDlg->SetHeading(438);
- else
- m_pDlg->SetHeading(m_strHeader);
+{
+ if (m_pDlg)
+ {
+ if (m_strHeader.IsEmpty())
+ m_pDlg->SetHeading(438);
+ else
+ m_pDlg->SetHeading(m_strHeader);
- m_pDlg->SetLine(2, m_strLinePrev);
- m_pDlg->StartModal();
+ m_pDlg->SetLine(2, m_strLinePrev);
+ m_pDlg->StartModal();
+ }
bSentCancel = false;
}
@@ -91,17 +98,23 @@ void CGUIDialogCache::SetHeader(int nHeader)
void CGUIDialogCache::SetMessage(const CStdString& strMessage)
{
- m_pDlg->SetLine(0, m_strLinePrev2);
- m_pDlg->SetLine(1, m_strLinePrev);
- m_pDlg->SetLine(2, strMessage);
+ if (m_pDlg)
+ {
+ m_pDlg->SetLine(0, m_strLinePrev2);
+ m_pDlg->SetLine(1, m_strLinePrev);
+ m_pDlg->SetLine(2, strMessage);
+ }
m_strLinePrev2 = m_strLinePrev;
m_strLinePrev = strMessage;
}
bool CGUIDialogCache::OnFileCallback(void* pContext, int ipercent, float avgSpeed)
{
- m_pDlg->ShowProgressBar(true);
- m_pDlg->SetPercentage(ipercent);
+ if (m_pDlg)
+ {
+ m_pDlg->ShowProgressBar(true);
+ m_pDlg->SetPercentage(ipercent);
+ }
if( IsCanceled() )
return false;
@@ -111,6 +124,9 @@ bool CGUIDialogCache::OnFileCallback(void* pContext, int ipercent, float avgSpee
void CGUIDialogCache::Process()
{
+ if (m_pDlg)
+ return;
+
while( true )
{
@@ -147,16 +163,20 @@ void CGUIDialogCache::Process()
}
void CGUIDialogCache::ShowProgressBar(bool bOnOff)
-{
- m_pDlg->ShowProgressBar(bOnOff);
+{
+ if (m_pDlg)
+ m_pDlg->ShowProgressBar(bOnOff);
}
+
void CGUIDialogCache::SetPercentage(int iPercentage)
{
- m_pDlg->SetPercentage(iPercentage);
+ if (m_pDlg)
+ m_pDlg->SetPercentage(iPercentage);
}
+
bool CGUIDialogCache::IsCanceled() const
{
- if (m_pDlg->IsDialogRunning())
+ if (m_pDlg && m_pDlg->IsDialogRunning())
return m_pDlg->IsCanceled();
else
return false;
Please sign in to comment.
Something went wrong with that request. Please try again.