From 4b0a40a825854d08d1acb1cb11a16375b1e57822 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sat, 12 Oct 2013 17:46:06 +1000 Subject: [PATCH] Resolve crash on empty days in previous code --- sleepyhead/daily.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index c811f6dd..cb773774 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -1323,15 +1323,18 @@ void Daily::Load(QDate date) QVector::iterator i; // WebView trashes it without asking.. :( - sessbar=new SessionBar(this); - sessbar->setMouseTracking(true); - connect(sessbar, SIGNAL(toggledSession(Session*)), this, SLOT(doToggleSession(Session*))); - int c=0; - for (i=cpap->begin();i!=cpap->end();++i) { - Session * s=*i; - sessbar->add(s, cols[c % maxcolors]); - c++; - } + if (cpap) { + sessbar=new SessionBar(this); + sessbar->setMouseTracking(true); + connect(sessbar, SIGNAL(toggledSession(Session*)), this, SLOT(doToggleSession(Session*))); + int c=0; + + for (i=cpap->begin();i!=cpap->end();++i) { + Session * s=*i; + sessbar->add(s, cols[c % maxcolors]); + c++; + } + } else sessbar=NULL; //sessbar->update(); webView->setHtml(html);