Enabled hog reindexing if Cache Sessions Data is enabled

This commit is contained in:
Mark Watkins 2012-01-10 20:26:34 +10:00
parent 2cb35b69c0
commit 1a3627f466
2 changed files with 30 additions and 13 deletions

View File

@ -327,6 +327,7 @@ bool Machine::Save()
}
savelistCnt=0;
savelistSize=m_savelist.size();
bool cachesessions=PROFILE.session->cacheSessions();
if (!PROFILE.session->multithreading()) {
for (int i=0;i<savelistSize;i++) {
if ((i % 10) ==0) {
@ -336,6 +337,7 @@ bool Machine::Save()
Session *s=m_savelist.at(i);
s->UpdateSummaries();
s->Store(path);
if (!cachesessions)
s->TrashEvents();
savelistCnt++;
@ -378,11 +380,14 @@ bool Machine::Save()
void SaveThread::run()
{
bool cachesessions=PROFILE.session->cacheSessions();
while (Session *sess=machine->popSaveList()) {
int i=(float(machine->savelistCnt)/float(machine->savelistSize)*100.0);
emit UpdateProgress(i);
sess->UpdateSummaries();
sess->Store(path);
if (!cachesessions)
sess->TrashEvents();
}
machine->savelistSem->release(1);

View File

@ -2513,22 +2513,28 @@ void MainWindow::doReprocessEvents()
int daycount=first.daysTo(date);
int idx=0;
//QList<Machine *> machines=PROFILE.GetMachines(MT_UNKNOWN);
QList<Machine *> machines=PROFILE.GetMachines(MT_UNKNOWN);
if (qprogress) {
bool cache_sessions=PROFILE.session->cacheSessions();
if (cache_sessions) { // Use multithreaded save to handle reindexing.. (hogs memory like hell)
qstatus->setText(tr("Loading Event Data"));
} else {
qstatus->setText(tr("Recalculating Summaries"));
//qstatus->setText(tr("Loading Event Data"));
}
if (qprogress) {
qprogress->setValue(0);
qprogress->setVisible(true);
}
bool isopen;
QDate current=daily->getDate();
do {
day=PROFILE.GetDay(date,MT_CPAP);
if (day) {
for (int i=0;i<day->size();i++) {
sess=(*day)[i];
bool isopen=sess->eventsLoaded();
// Load the events
isopen=sess->eventsLoaded();
// Load the events if they aren't loaded already
sess->OpenEvents();
//if (!sess->channelDataExists(CPAP_FlowRate)) continue;
@ -2545,9 +2551,12 @@ void MainWindow::doReprocessEvents()
sess->destroyEvent(CPAP_RDI);
sess->SetChanged(true);
if (!cache_sessions) {
sess->UpdateSummaries();
sess->machine()->SaveSession(sess);
if (!isopen) sess->TrashEvents();
if (!isopen)
sess->TrashEvents();
}
}
}
date=date.addDays(-1);
@ -2558,9 +2567,12 @@ void MainWindow::doReprocessEvents()
} while (date>=first);
// for (int i=0;i<machines.size();i++) {
// machines.at(i)->Save();
// }
if (cache_sessions) {
qstatus->setText(tr("Recalculating Summaries"));
for (int i=0;i<machines.size();i++) {
machines.at(i)->Save();
}
}
qstatus->setText(tr(""));
qprogress->setVisible(false);