From 97de959783d5a3e0566cb4477a01816fdfe510e8 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Mon, 14 Sep 2015 20:47:05 -0400 Subject: [PATCH] Fixed issues with phantom records when filtering the main frame display. Updated version number and required GVRET version since GVRET has had some important fixes recently. --- canframemodel.cpp | 20 +++++++++++++------- canframemodel.h | 1 + config.h | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index df8b713..e62766c 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -32,6 +32,7 @@ CANFrameModel::CANFrameModel(QObject *parent) timeSeconds = false; timeOffset = 0; needFilterRefresh = false; + lastUpdateNumFrames = 0; } void CANFrameModel::setHexMode(bool mode) @@ -323,6 +324,7 @@ void CANFrameModel::sendRefresh() filteredFrames.append(frames[i]); } } + lastUpdateNumFrames = filteredFrames.count(); endResetModel(); } @@ -337,19 +339,22 @@ void CANFrameModel::sendRefresh(int pos) //have to send thousands of messages per second void CANFrameModel::sendBulkRefresh(int num) { + //yes, num was sent to us by the serial worker but we actually have a better idea + //of how many by tracking the number we last knew about as opposed to how many rows there + //are now. + num = filteredFrames.count() - lastUpdateNumFrames; + lastUpdateNumFrames += num; //done this way to avoid asking for filteredFrames.count() again + //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 (filteredFrames.count() == 0) return; if (!overwriteDups) - { + { if (num > filteredFrames.count()) num = filteredFrames.count(); - beginInsertRows(QModelIndex(), frames.count() - num, frames.count() - 1); + beginInsertRows(QModelIndex(), filteredFrames.count() - num, filteredFrames.count() - 1); endInsertRows(); - } else { @@ -365,6 +370,7 @@ void CANFrameModel::clearFrames() filteredFrames.clear(); filters.clear(); this->endResetModel(); + lastUpdateNumFrames = 0; mutex.unlock(); emit updatedFiltersList(); diff --git a/canframemodel.h b/canframemodel.h index dee0651..98a3d5c 100644 --- a/canframemodel.h +++ b/canframemodel.h @@ -61,6 +61,7 @@ private: bool timeSeconds; bool needFilterRefresh; uint64_t timeOffset; + int lastUpdateNumFrames; }; diff --git a/config.h b/config.h index b2ee918..2fb974b 100644 --- a/config.h +++ b/config.h @@ -1,12 +1,12 @@ #ifndef CONFIG #define CONFIG -#define VERSION 137 +#define VERSION 138 //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision //less than this number. -#define CURRENT_GVRET_VER 323 +#define CURRENT_GVRET_VER 325 #endif // CONFIG