Merge branch 'add_allowfilterstostayuponclear'

This commit is contained in:
Andy Huska
2022-09-23 15:51:02 -05:00
+8 -17
View File
@@ -61,8 +61,9 @@ CANFrameModel::CANFrameModel(QObject *parent)
QSettings settings; QSettings settings;
preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt(); preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt();
//the goal is to prevent a reallocation from ever happening
frames.reserve(preallocSize); frames.reserve(preallocSize);
filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening filteredFrames.reserve(preallocSize);
dbcHandler = DBCHandler::getReference(); dbcHandler = DBCHandler::getReference();
interpretFrames = false; interpretFrames = false;
@@ -683,24 +684,10 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
if (!overwriteDups) if (!overwriteDups)
{ {
bool alloc_ok = true; try
for(int i=0; i<3; i++)
{ {
try frames.append(tempFrame);
{
frames.append(tempFrame);
break;
}
catch (const std::exception& ex)
{
alloc_ok = false;
qDebug() << "addFrame failed to append. frames.length(): " << frames.length() << " Exception: " << ex.what();
}
}
if(alloc_ok)
{
if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus]) if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus])
{ {
if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count()); if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count());
@@ -709,6 +696,10 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
if (autoRefresh) endInsertRows(); if (autoRefresh) endInsertRows();
} }
} }
catch (const std::exception& ex)
{
qDebug() << "addFrame failed to append. App is probably going to crash. frames.length(): " << frames.length() << " Exception: " << ex.what();
}
} }
else //yes, overwrite dups else //yes, overwrite dups
{ {