Fixed issue where filteredFrames was having its capacity changed
when adjusting filters due to appending a QVector of frames which appears to change the capacity to the number of items appended. Also fixed bug where preallocsize was being locally defined and therefore the global version wasn't being updated with unknown effets.
This commit is contained in:
+6
-6
@@ -59,7 +59,7 @@ CANFrameModel::CANFrameModel(QObject *parent)
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
int preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt();
|
||||
preallocSize = settings.value("Main/MaximumFrames", maxFramesDefault).toInt();
|
||||
|
||||
frames.reserve(preallocSize);
|
||||
filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening
|
||||
@@ -752,15 +752,15 @@ void CANFrameModel::addFrames(const CANConnection*, const QVector<CANFrame>& pFr
|
||||
{
|
||||
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 count: " << frames.length() << " of " << frames.capacity() << " capacity, removing first " << (int)(frames.capacity() * 0.05) << " frames";
|
||||
frames.remove(0, (int)(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 count: " << filteredFrames.length() << " of " << filteredFrames.capacity() << " capacity, removing first " << (int)(filteredFrames.capacity() * 0.05) << " frames";
|
||||
filteredFrames.remove(0, (int)(filteredFrames.capacity() * 0.05));
|
||||
qDebug() << "filteredFrames removed, new count: " << filteredFrames.length();
|
||||
}
|
||||
|
||||
@@ -790,8 +790,8 @@ void CANFrameModel::sendRefresh()
|
||||
mutex.lock();
|
||||
beginResetModel();
|
||||
filteredFrames.clear();
|
||||
filteredFrames.reserve(preallocSize);
|
||||
filteredFrames.append(tempContainer);
|
||||
filteredFrames.reserve(preallocSize);
|
||||
|
||||
lastUpdateNumFrames = 0;
|
||||
endResetModel();
|
||||
|
||||
Reference in New Issue
Block a user