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;
preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt();
//the goal is to prevent a reallocation from ever happening
frames.reserve(preallocSize);
filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening
filteredFrames.reserve(preallocSize);
dbcHandler = DBCHandler::getReference();
interpretFrames = false;
@@ -683,24 +684,10 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
if (!overwriteDups)
{
bool alloc_ok = true;
for(int i=0; i<3; i++)
try
{
try
{
frames.append(tempFrame);
break;
}
catch (const std::exception& ex)
{
alloc_ok = false;
qDebug() << "addFrame failed to append. frames.length(): " << frames.length() << " Exception: " << ex.what();
}
}
frames.append(tempFrame);
if(alloc_ok)
{
if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus])
{
if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count());
@@ -709,6 +696,10 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
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
{