Added frames per second read out. Fixed some crashes.

This commit is contained in:
Collin Kidder
2015-05-24 10:10:27 -04:00
parent f18411c567
commit 06ee0c9301
7 changed files with 66 additions and 13 deletions
+10
View File
@@ -128,9 +128,11 @@ QVariant CANFrameModel::headerData(int section, Qt::Orientation orientation,
void CANFrameModel::addFrame(CANFrame &frame, bool autoRefresh = false)
{
mutex.lock();
if (autoRefresh) beginInsertRows(QModelIndex(), frames.count() + 1, frames.count() + 1);
frames.append(frame);
if (autoRefresh) endInsertRows();
mutex.unlock();
}
void CANFrameModel::sendRefresh()
@@ -151,15 +153,23 @@ void CANFrameModel::sendRefresh(int pos)
void CANFrameModel::sendBulkRefresh(int num)
{
//qDebug() << "Bulk refresh of " << num;
//the next three lines protect against a crash in case someone clicked clear frames
//in between the time we got some frames and the time this was called
//otherwise it's possible that the grid is in an odd state.
if (num == 0) return;
if (frames.count() == 0) return;
if (num > frames.count()) num = frames.count();
beginInsertRows(QModelIndex(), frames.count() - num, frames.count() - 1);
endInsertRows();
}
void CANFrameModel::clearFrames()
{
mutex.lock();
this->beginResetModel();
frames.clear();
this->endResetModel();
mutex.unlock();
}
//Is this safe? Maybe not but if we don't change it then that's OK