mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
FeedReader:
- added new setting to save the config in the background for slow systems - fixed memory leak in p3FeedReader::saveList git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6349 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
05f8b15cfe
commit
a497157110
6 changed files with 99 additions and 13 deletions
|
@ -50,6 +50,7 @@ p3FeedReader::p3FeedReader(RsPluginHandler* pgHandler)
|
|||
mStandardProxyPort = 0;
|
||||
mLastClean = 0;
|
||||
mNotify = NULL;
|
||||
mSaveInBackground = false;
|
||||
|
||||
mPreviewDownloadThread = NULL;
|
||||
mPreviewProcessThread = NULL;
|
||||
|
@ -273,6 +274,23 @@ void p3FeedReader::setStandardProxy(bool useProxy, const std::string &proxyAddre
|
|||
}
|
||||
}
|
||||
|
||||
bool p3FeedReader::getSaveInBackground()
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
return mSaveInBackground;
|
||||
}
|
||||
|
||||
void p3FeedReader::setSaveInBackground(bool saveInBackground)
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
if (saveInBackground != mSaveInBackground) {
|
||||
mSaveInBackground = saveInBackground;
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void p3FeedReader::stop()
|
||||
{
|
||||
{
|
||||
|
@ -1344,11 +1362,15 @@ RsSerialiser *p3FeedReader::setupSerialiser()
|
|||
return rss;
|
||||
}
|
||||
|
||||
bool p3FeedReader::saveList(bool &cleanup, std::list<RsItem *> & saveData)
|
||||
bool p3FeedReader::saveList(bool &cleanup, std::list<RsItem *> &saveData)
|
||||
{
|
||||
mFeedReaderMtx.lock(); /*********************** LOCK *******/
|
||||
|
||||
cleanup = false;
|
||||
if (mSaveInBackground) {
|
||||
cleanup = true;
|
||||
} else {
|
||||
cleanup = false;
|
||||
}
|
||||
|
||||
RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet();
|
||||
|
||||
|
@ -1373,8 +1395,15 @@ bool p3FeedReader::saveList(bool &cleanup, std::list<RsItem *> & saveData)
|
|||
rs_sprintf(kv.value, "%hu", mStandardProxyPort);
|
||||
rskv->tlvkvs.pairs.push_back(kv);
|
||||
|
||||
kv.key = "SaveInBackground";
|
||||
rs_sprintf(kv.value, "%hu", mSaveInBackground ? 1 : 0);
|
||||
rskv->tlvkvs.pairs.push_back(kv);
|
||||
|
||||
/* Add KeyValue to saveList */
|
||||
saveData.push_back(rskv);
|
||||
if (!cleanup) {
|
||||
cleanSaveData.push_back(rskv);
|
||||
}
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed *>::iterator it1;
|
||||
for (it1 = mFeeds.begin(); it1 != mFeeds.end(); ++it1) {
|
||||
|
@ -1382,22 +1411,44 @@ bool p3FeedReader::saveList(bool &cleanup, std::list<RsItem *> & saveData)
|
|||
if (fi->preview) {
|
||||
continue;
|
||||
}
|
||||
saveData.push_back(fi);
|
||||
if (cleanup) {
|
||||
saveData.push_back(new RsFeedReaderFeed(*fi));
|
||||
} else {
|
||||
saveData.push_back(fi);
|
||||
}
|
||||
|
||||
std::map<std::string, RsFeedReaderMsg*>::iterator it2;
|
||||
for (it2 = fi->msgs.begin(); it2 != fi->msgs.end(); ++it2) {
|
||||
saveData.push_back(it2->second);
|
||||
RsFeedReaderMsg *msg = it2->second;
|
||||
|
||||
if (cleanup) {
|
||||
saveData.push_back(new RsFeedReaderMsg(*msg));
|
||||
} else {
|
||||
saveData.push_back(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mSaveInBackground) {
|
||||
mFeedReaderMtx.unlock(); /*********************** UNLOCK *******/
|
||||
}
|
||||
|
||||
/* list completed! */
|
||||
return true;
|
||||
}
|
||||
|
||||
void p3FeedReader::saveDone()
|
||||
{
|
||||
mFeedReaderMtx.unlock(); /*********************** UNLOCK *******/
|
||||
return;
|
||||
{
|
||||
/* clean settings items */
|
||||
std::list<RsItem*>::iterator it;
|
||||
for (it = cleanSaveData.begin(); it != cleanSaveData.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
cleanSaveData.clear();
|
||||
|
||||
if (!mSaveInBackground) {
|
||||
mFeedReaderMtx.unlock(); /*********************** UNLOCK *******/
|
||||
}
|
||||
}
|
||||
|
||||
bool p3FeedReader::loadList(std::list<RsItem *>& load)
|
||||
|
@ -1466,6 +1517,11 @@ bool p3FeedReader::loadList(std::list<RsItem *>& load)
|
|||
if (sscanf(kit->value.c_str(), "%hu", &value) == 1) {
|
||||
mStandardProxyPort = value;
|
||||
}
|
||||
} else if (kit->key == "SaveInBackground") {
|
||||
uint16_t value;
|
||||
if (sscanf(kit->value.c_str(), "%hu", &value) == 1) {
|
||||
mSaveInBackground = value == 1 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue