Fix Crash due loader not found

This commit is contained in:
LoudSnorer 2024-07-06 12:01:53 -04:00
parent 6acbe28566
commit 4c1c17287d
3 changed files with 30 additions and 13 deletions

View File

@ -1452,6 +1452,7 @@ int Day::getCPAPMode()
if (!mach) return 0;
CPAPLoader * loader = qobject_cast<CPAPLoader *>(mach->loader());
if (!loader) return 0;
ChannelID modechan = loader->CPAPModeChannel();
*/
@ -1472,6 +1473,9 @@ QString Day::getCPAPModeStr()
if (!mach) return STR_MessageBox_Error;
CPAPLoader * loader = qobject_cast<CPAPLoader *>(mach->loader());
if (!loader) {
return QObject::tr("ERROR:NOT AVAILABLE"); //STR_MessageBox_Error;
}
ChannelID modechan = loader->CPAPModeChannel();
@ -1511,8 +1515,9 @@ QString Day::getPressureRelief()
if (!mach) return STR_MessageBox_Error;
CPAPLoader * loader = qobject_cast<CPAPLoader *>(mach->loader());
if (!loader) return STR_MessageBox_Error;
if (!loader) {
return QObject::tr("ERROR:NOT AVAILABLE"); //STR_MessageBox_Error;
}
QString pr_str;

View File

@ -1114,9 +1114,13 @@ QString Daily::getSessionInformation(Day * day)
QString Daily::getMachineSettings(Day * day) {
QString html;
Machine * cpap = day->machine(MT_CPAP);
if (cpap && day->hasEnabledSessions(MT_CPAP)) {
CPAPLoader * loader = qobject_cast<CPAPLoader *>(cpap->loader());
if (!loader) {
htmlLsbSectionHeader(html,tr("DEVICE SETTINGS ERROR"),LSB_DEVICE_SETTINGS );
return html;
}
htmlLsbSectionHeader(html,tr("Device Settings"),LSB_DEVICE_SETTINGS );
if (!leftSideBarEnable[LSB_DEVICE_SETTINGS] ) {
return html;
@ -1139,8 +1143,6 @@ QString Daily::getMachineSettings(Day * day) {
}
QMap<int, QString> first;
CPAPLoader * loader = qobject_cast<CPAPLoader *>(cpap->loader());
ChannelID cpapmode = loader->CPAPModeChannel();
schema::Channel & chan = schema::channel[cpapmode];
first[cpapmode] = QString("<tr><td><p title='%2'>%1</p></td><td colspan=4>%3</td></tr>")

View File

@ -108,7 +108,8 @@ QDataStream & operator>>(QDataStream & in, RXItem & rx)
if (loader) {
rx.machine = p_profile->lookupMachine(serial, loadername);
} else {
qDebug() << "Bad machine object" << loadername << serial;
qDebug() << "Bad machine object" << loadername << serial << (void*)loader;
rx.machine = nullptr;
}
@ -180,7 +181,9 @@ void Statistics::loadRXChanges()
QList<QDate> toErase;
for (auto ri = rxitems.begin(); ri != rxitems.end();++ri ) {
RXItem rxitem = ri.value();
if (rxitem.machine==0) toErase.append(ri.key());
if (rxitem.machine==nullptr) {
toErase.append(ri.key());
}
}
for (auto date : toErase) {
rxitems.remove(date) ;
@ -339,6 +342,9 @@ void Statistics::updateRXChanges()
// Read the cache from disk
loadRXChanges();
if (rxitems.size() == 0) {
return;
}
QMap<QDate, Day *>::iterator di;
QMap<QDate, Day *>::iterator it;
@ -560,6 +566,10 @@ void Statistics::updateRXChanges()
}
}
}
if (rxitems.size() == 0) {
return;
}
if (fnd) continue; // already in rx list, move onto the next daylist entry