Merge branch 'master' into fix_dbc_creation
This commit is contained in:
+10
-19
@@ -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;
|
||||
@@ -415,7 +416,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(thisFrame.payload().constData());
|
||||
int dataLen = thisFrame.payload().count();
|
||||
|
||||
if (role == Qt::BackgroundColorRole)
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors)
|
||||
{
|
||||
@@ -448,7 +449,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::TextColorRole)
|
||||
if (role == Qt::ForegroundRole)
|
||||
{
|
||||
if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors)
|
||||
{
|
||||
@@ -684,24 +685,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());
|
||||
@@ -710,6 +697,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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user