From f38e0b0bfaecd7197fa00cae2e7d9dfd1100b637 Mon Sep 17 00:00:00 2001 From: Andy Huska Date: Fri, 23 Sep 2022 15:28:41 -0500 Subject: [PATCH] Took out unnecessary exception recover code Cuz app is going to crash anyway, no need to make a mess --- canframemodel.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index 8ca4a5a..94f3ce0 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -61,8 +61,9 @@ CANFrameModel::CANFrameModel(QObject *parent) QSettings settings; int 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; @@ -685,18 +686,14 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false) { 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); + } + catch (const std::exception& ex) + { + alloc_ok = false; + qDebug() << "addFrame failed to append. App is probably going to crash. frames.length(): " << frames.length() << " Exception: " << ex.what(); } if(alloc_ok)