Free memory when leaving day

This commit is contained in:
Mark Watkins 2011-07-27 20:47:50 +10:00
parent e8c7222143
commit 8c788b30c6
5 changed files with 15 additions and 7 deletions

View File

@ -136,7 +136,7 @@ void DrawText(gGraphWindow &wid,QString text, int x, int y, float angle, QColor
{
if (angle==90) {
//TextBuffer *b=new TextBuffer(text,x,y,angle,color,font);
TextQueRot.push_back(TextBuffer(text,x,y,angle,color,font));
// TextQueRot.push_back(TextBuffer(text,x,y,angle,color,font));
} else {
wid.qglColor(color);
wid.renderText(x,wid.GetScrY()-y,0,text,*font);

View File

@ -632,12 +632,6 @@ void gGraphWindow::OnMouseLeftDown(QMouseEvent * event)
if (x<GetLeftMargin()) {
LastGraphLDown=this;
m_dragGraph=true;
/* QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
mimeData->setText("BiteMe");
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec(); */
return;
}
int width=m_scrX-GetRightMargin()-GetLeftMargin();

View File

@ -441,6 +441,7 @@ bool Machine::Save()
cnt++;
if (qprogress) qprogress->setValue(66.0+(float(cnt)/float(size)*33.0));
if ((*s)->IsChanged()) (*s)->Store(path);
(*s)->TrashEvents();
}
//qDebug() << "Day Save Completed";

View File

@ -44,6 +44,7 @@ void Session::TrashEvents()
delete *j;
}
}
s_events_loaded=false;
eventlist.clear();
}
@ -77,11 +78,15 @@ bool Session::Store(QString path)
bool a;
a=StoreSummary(base+".000"); // if actually has events
//qDebug() << " Summary done";
s_eventfile=base+".001";
if (eventlist.size()>0) StoreEvents(base+".001");
//qDebug() << " Events done";
if (a) {
s_changed=false;
s_events_loaded=true;
//TrashEvents();
}
return a;
}

View File

@ -411,11 +411,18 @@ void Daily::on_calendar_selectionChanged()
}
void Daily::Load(QDate date)
{
static Day * lastcpapday=NULL;
previous_date=date;
Day *cpap=profile->GetDay(date,MT_CPAP);
Day *oxi=profile->GetDay(date,MT_OXIMETER);
// Day *sleepstage=profile->GetDay(date,MT_SLEEPSTAGE);
if (lastcpapday && (lastcpapday!=cpap)) {
for (vector<Session *>::iterator s=lastcpapday->begin();s!=lastcpapday->end();s++) {
(*s)->TrashEvents();
}
}
lastcpapday=cpap;
QString html="<html><head><style type='text/css'>p,a,td,body { font-family: 'FreeSans', 'Sans Serif'; } p,a,td,body { font-size: 12px; } </style>"
"</head>"
"<body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0>"
@ -823,6 +830,7 @@ void Daily::UpdateCPAPGraphs(Day *day)
void Daily::UpdateOXIGraphs(Day *day)
{
//if (!day) return;
if (day) {
day->OpenEvents();
}