Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pvr: replaced delete + NULL by SAFE_DELETE

  • Loading branch information...
commit b2ce64b86f24f6e64a20c9350c3c688bb13066be 1 parent f2bc2c6
@opdenkamp authored
View
6 xbmc/pvr/PVRGUIInfo.cpp
@@ -810,10 +810,8 @@ int CPVRGUIInfo::GetStartTime(void) const
void CPVRGUIInfo::ResetPlayingTag(void)
{
CSingleLock lock(m_critSection);
- if (m_playingEpgTag)
- delete m_playingEpgTag;
- m_playingEpgTag = NULL;
- m_iDuration = 0;
+ SAFE_DELETE(m_playingEpgTag);
+ m_iDuration = 0;
}
bool CPVRGUIInfo::GetPlayingTag(CEpgInfoTag &tag) const
View
22 xbmc/pvr/PVRManager.cpp
@@ -85,11 +85,11 @@ void CPVRManager::Cleanup(void)
{
CSingleLock lock(m_critSection);
- if (m_addons) delete m_addons; m_addons = NULL;
- if (m_guiInfo) delete m_guiInfo; m_guiInfo = NULL;
- if (m_timers) delete m_timers; m_timers = NULL;
- if (m_recordings) delete m_recordings; m_recordings = NULL;
- if (m_channelGroups) delete m_channelGroups; m_channelGroups = NULL;
+ if (m_addons) SAFE_DELETE(m_addons);
+ if (m_guiInfo) SAFE_DELETE(m_guiInfo);
+ if (m_timers) SAFE_DELETE(m_timers);
+ if (m_recordings) SAFE_DELETE(m_recordings);
+ if (m_channelGroups) SAFE_DELETE(m_channelGroups);
m_triggerEvent.Set();
m_currentFile = NULL;
@@ -738,11 +738,7 @@ void CPVRManager::CloseStream(void)
}
m_addons->CloseStream();
- if (m_currentFile)
- {
- delete m_currentFile;
- m_currentFile = NULL;
- }
+ SAFE_DELETE(m_currentFile);
}
void CPVRManager::UpdateCurrentFile(void)
@@ -849,11 +845,7 @@ bool CPVRManager::PerformChannelSwitch(const CPVRChannel &channel, bool bPreview
if (!bPreview)
SaveCurrentChannelSettings();
- if (m_currentFile)
- {
- delete m_currentFile;
- m_currentFile = NULL;
- }
+ SAFE_DELETE(m_currentFile);
lock.Leave();
View
82 xbmc/pvr/windows/GUIWindowPVR.cpp
@@ -38,12 +38,17 @@
using namespace PVR;
CGUIWindowPVR::CGUIWindowPVR(void) :
- CGUIMediaWindow(WINDOW_PVR, "MyPVR.xml")
+ CGUIMediaWindow(WINDOW_PVR, "MyPVR.xml"),
+ m_guideGrid(NULL),
+ m_currentSubwindow(NULL),
+ m_savedSubwindow(NULL),
+ m_windowChannelsTV(NULL),
+ m_windowChannelsRadio(NULL),
+ m_windowGuide(NULL),
+ m_windowRecordings(NULL),
+ m_windowSearch(NULL),
+ m_windowTimers(NULL)
{
- m_guideGrid = NULL;
- m_bViewsCreated = false;
- m_currentSubwindow = NULL;
- m_savedSubwindow = NULL;
}
CGUIWindowPVR::~CGUIWindowPVR(void)
@@ -54,18 +59,12 @@ CGUIWindowPVR::~CGUIWindowPVR(void)
CGUIWindowPVRCommon *CGUIWindowPVR::GetActiveView(void) const
{
CSingleLock lock(m_critSection);
- if (!m_bViewsCreated)
- return NULL;
-
return m_currentSubwindow;
}
void CGUIWindowPVR::SetActiveView(CGUIWindowPVRCommon *window)
{
CSingleLock lock(m_critSection);
- if (!m_bViewsCreated)
- return;
-
m_currentSubwindow = window;
}
@@ -81,9 +80,6 @@ void CGUIWindowPVR::GetContextButtons(int itemNumber, CContextButtons &buttons)
CGUIWindowPVRCommon *CGUIWindowPVR::GetSavedView(void) const
{
CSingleLock lock(m_critSection);
- if (!m_bViewsCreated)
- return NULL;
-
return m_savedSubwindow;
}
@@ -230,17 +226,23 @@ bool CGUIWindowPVR::OnMessageClick(CGUIMessage &message)
void CGUIWindowPVR::CreateViews(void)
{
CSingleLock lock(m_critSection);
- if (!m_bViewsCreated)
- {
- m_bViewsCreated = true;
-
+ if (!m_windowChannelsRadio)
m_windowChannelsRadio = new CGUIWindowPVRChannels(this, true);
- m_windowChannelsTV = new CGUIWindowPVRChannels(this, false);
- m_windowGuide = new CGUIWindowPVRGuide(this);
- m_windowRecordings = new CGUIWindowPVRRecordings(this);
- m_windowSearch = new CGUIWindowPVRSearch(this);
- m_windowTimers = new CGUIWindowPVRTimers(this);
- }
+
+ if (!m_windowChannelsTV)
+ m_windowChannelsTV = new CGUIWindowPVRChannels(this, false);
+
+ if (!m_windowGuide)
+ m_windowGuide = new CGUIWindowPVRGuide(this);
+
+ if (!m_windowRecordings)
+ m_windowRecordings = new CGUIWindowPVRRecordings(this);
+
+ if (!m_windowSearch)
+ m_windowSearch = new CGUIWindowPVRSearch(this);
+
+ if (!m_windowTimers)
+ m_windowTimers = new CGUIWindowPVRTimers(this);
}
void CGUIWindowPVR::Reset(void)
@@ -256,33 +258,35 @@ void CGUIWindowPVR::Reset(void)
m_windowGuide->ResetObservers();
m_windowRecordings->ResetObservers();
m_windowTimers->ResetObservers();
-
- m_currentSubwindow = NULL;
- m_savedSubwindow = NULL;
- ClearFileItems();
- FreeResources();
}
void CGUIWindowPVR::Cleanup(void)
{
- if (m_bViewsCreated)
- {
+ if (m_windowChannelsRadio)
m_windowChannelsRadio->UnregisterObservers();
- delete m_windowChannelsRadio;
+ SAFE_DELETE(m_windowChannelsRadio);
+ if (m_windowChannelsTV)
m_windowChannelsTV->UnregisterObservers();
- delete m_windowChannelsTV;
+ SAFE_DELETE(m_windowChannelsTV);
+ if (m_windowGuide)
m_windowGuide->UnregisterObservers();
- delete m_windowGuide;
+ SAFE_DELETE(m_windowGuide);
+ if (m_windowRecordings)
m_windowRecordings->UnregisterObservers();
- delete m_windowRecordings;
+ SAFE_DELETE(m_windowRecordings);
- delete m_windowSearch;
+ SAFE_DELETE(m_windowSearch);
+ if (m_windowTimers)
m_windowTimers->UnregisterObservers();
- delete m_windowTimers;
- m_bViewsCreated = false;
- }
+ SAFE_DELETE(m_windowTimers);
+
+ m_currentSubwindow = NULL;
+ m_savedSubwindow = NULL;
+
+ ClearFileItems();
+ FreeResources();
}
View
1  xbmc/pvr/windows/GUIWindowPVR.h
@@ -83,7 +83,6 @@ namespace PVR
CGUIWindowPVRSearch * m_windowSearch;
CGUIWindowPVRTimers * m_windowTimers;
- bool m_bViewsCreated;
CCriticalSection m_critSection;
};
}
Please sign in to comment.
Something went wrong with that request. Please try again.