Commit
…abase updates. closes #81
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -464,6 +464,12 @@ bool CPVRDatabase::RemoveChannelsFromGroup(const CPVRChannelGroup &group) | |
return DeleteValues("map_channelgroups_channels", strWhereClause); | ||
} | ||
|
||
bool CPVRDatabase::RemoveStaleChannelsFromGroup(const CPVRChannelGroup &group) | ||
{ | ||
CStdString strWhereClause = FormatSQL("idGroup = %u AND iChannelNumber > %u", group.GroupID(), group.size()); | ||
return DeleteValues("map_channelgroups_channels", strWhereClause); | ||
} | ||
|
||
bool CPVRDatabase::DeleteChannelGroups(void) | ||
{ | ||
CLog::Log(LOGDEBUG, "PVRDB - %s - deleting all channel groups from the database", __FUNCTION__); | ||
|
@@ -600,27 +606,36 @@ bool CPVRDatabase::Persist(CPVRChannelGroup &group) | |
|
||
bool CPVRDatabase::PersistGroupMembers(CPVRChannelGroup &group) | ||
{ | ||
bool bReturn = RemoveChannelsFromGroup(group); | ||
bool bReturn = false; | ||
bool bRemoveChannels = false; | ||
CStdString strQuery; | ||
CSingleLock lock(group.m_critSection); | ||
|
||
if (bReturn && group.size() > 0) | ||
if (group.size() > 0) | ||
{ | ||
for (unsigned int iChannelPtr = 0; iChannelPtr < group.size(); iChannelPtr++) | ||
{ | ||
PVRChannelGroupMember member = group.at(iChannelPtr); | ||
strQuery = FormatSQL("REPLACE INTO map_channelgroups_channels (" | ||
"idGroup, idChannel, iChannelNumber) " | ||
"VALUES (%i, %i, %i);", | ||
group.GroupID(), member.channel->ChannelID(), member.iChannelNumber); | ||
QueueInsertQuery(strQuery); | ||
|
||
CStdString strWhereClause = FormatSQL("idChannel = %u AND idGroup = %u AND iChannelNumber = %u", | ||
member.channel->ChannelID(), group.GroupID(), member.iChannelNumber); | ||
|
||
CStdString strValue = GetSingleValue("map_channelgroups_channels", "idChannel", strWhereClause); | ||
if (strValue.IsEmpty()) { | ||
strQuery = FormatSQL("REPLACE INTO map_channelgroups_channels (" | ||
"idGroup, idChannel, iChannelNumber) " | ||
"VALUES (%i, %i, %i);", | ||
group.GroupID(), member.channel->ChannelID(), member.iChannelNumber); | ||
QueueInsertQuery(strQuery); | ||
} | ||
} | ||
lock.Leave(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
opdenkamp
Owner
|
||
|
||
bReturn = CommitInsertQueries(); | ||
bRemoveChannels = RemoveStaleChannelsFromGroup(group); | ||
} | ||
|
||
return bReturn; | ||
return bReturn && bRemoveChannels; | ||
} | ||
|
||
/********** Client methods **********/ | ||
|
7 comments
on commit a34880d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if the if part is false (leave never executed), we leave the lock when the function exits, right (just want to get this straight)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, when the CSingleLock is destroyed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanx. Just one more thing: I have noticed that if I leave XBMC open when I leave home in the morning and check back in the afternoon, it has become very laggy and needs to be restarted in order to work properly. Maybe there is a memory leak somewhere (?)
Btw, I know this is not the right place to post this, please instruct where to post the general (but private) talk (not to be filed as issues)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be a memory leak indeed.
you could contact me using github's messaging service, #xbmc-pvr on freenode or the xbmc forums. no reason to keep things like this private though, since others who have the same question can find the answer, or other (team xbmc) devs can comment on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nemphys: checking out .xbmc/temp/xbmc.log should give a clue what xbmc is doing when it's laggy. also monitor it's cpu usage with htop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, already doing that, of course, but it doesn't always give a hint about where the problem is, unless the specifc function is set to log things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind, i only found out somewhat later that you were a coder :)
Just noticed this: should the lock.leave() be here, or outside the if?