Merge branch 'fix_addframebadalloc'
This commit is contained in:
+38
-6
@@ -673,13 +673,31 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
|
|||||||
|
|
||||||
if (!overwriteDups)
|
if (!overwriteDups)
|
||||||
{
|
{
|
||||||
frames.append(tempFrame);
|
bool alloc_ok = true;
|
||||||
if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus])
|
|
||||||
|
for(int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count());
|
try
|
||||||
tempFrame.frameCount = 1;
|
{
|
||||||
filteredFrames.append(tempFrame);
|
frames.append(tempFrame);
|
||||||
if (autoRefresh) endInsertRows();
|
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 (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count());
|
||||||
|
tempFrame.frameCount = 1;
|
||||||
|
filteredFrames.append(tempFrame);
|
||||||
|
if (autoRefresh) endInsertRows();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //yes, overwrite dups
|
else //yes, overwrite dups
|
||||||
@@ -728,6 +746,20 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
|
|||||||
|
|
||||||
void CANFrameModel::addFrames(const CANConnection*, const QVector<CANFrame>& pFrames)
|
void CANFrameModel::addFrames(const CANConnection*, const QVector<CANFrame>& pFrames)
|
||||||
{
|
{
|
||||||
|
if(frames.length() > frames.capacity() * 0.99)
|
||||||
|
{
|
||||||
|
qDebug() << "Frames count: " << frames.length() << " of " << frames.capacity() << " capacity, removing first " << frames.capacity() * 0.05 << " frames";
|
||||||
|
frames.remove(0, frames.capacity() * 0.05);
|
||||||
|
qDebug() << "Frames removed, new count: " << frames.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filteredFrames.length() > filteredFrames.capacity() * 0.99)
|
||||||
|
{
|
||||||
|
qDebug() << "filteredFrames count: " << filteredFrames.length() << " of " << filteredFrames.capacity() << " capacity, removing first " << filteredFrames.capacity() * 0.05 << " frames";
|
||||||
|
filteredFrames.remove(0, filteredFrames.capacity() * 0.05);
|
||||||
|
qDebug() << "filteredFrames removed, new count: " << filteredFrames.length();
|
||||||
|
}
|
||||||
|
|
||||||
foreach(const CANFrame& frame, pFrames)
|
foreach(const CANFrame& frame, pFrames)
|
||||||
{
|
{
|
||||||
addFrame(frame);
|
addFrame(frame);
|
||||||
|
|||||||
Reference in New Issue
Block a user