Merge branch 'master' into fix_dbc_creation
This commit is contained in:
+10
-19
@@ -61,8 +61,9 @@ CANFrameModel::CANFrameModel(QObject *parent)
|
||||
QSettings settings;
|
||||
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;
|
||||
@@ -415,7 +416,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(thisFrame.payload().constData());
|
||||
int dataLen = thisFrame.payload().count();
|
||||
|
||||
if (role == Qt::BackgroundColorRole)
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors)
|
||||
{
|
||||
@@ -448,7 +449,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::TextColorRole)
|
||||
if (role == Qt::ForegroundRole)
|
||||
{
|
||||
if (dbcHandler != nullptr && interpretFrames && !ignoreDBCColors)
|
||||
{
|
||||
@@ -684,24 +685,10 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
|
||||
|
||||
if (!overwriteDups)
|
||||
{
|
||||
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);
|
||||
|
||||
if(alloc_ok)
|
||||
{
|
||||
if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus])
|
||||
{
|
||||
if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count());
|
||||
@@ -710,6 +697,10 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
|
||||
if (autoRefresh) endInsertRows();
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
qDebug() << "addFrame failed to append. App is probably going to crash. frames.length(): " << frames.length() << " Exception: " << ex.what();
|
||||
}
|
||||
}
|
||||
else //yes, overwrite dups
|
||||
{
|
||||
|
||||
@@ -245,11 +245,11 @@ CANCon::type CANConnection::getType() {
|
||||
|
||||
|
||||
CANCon::status CANConnection::getStatus() {
|
||||
return (CANCon::status) mStatus.load();
|
||||
return (CANCon::status) mStatus.loadRelaxed();
|
||||
}
|
||||
|
||||
void CANConnection::setStatus(CANCon::status pStatus) {
|
||||
mStatus.store(pStatus);
|
||||
mStatus.storeRelaxed(pStatus);
|
||||
}
|
||||
|
||||
bool CANConnection::isCapSuspended() {
|
||||
|
||||
@@ -501,8 +501,10 @@ CANConnection* ConnectionWindow::create(CANCon::type pTye, QString pPortName, QS
|
||||
|
||||
void ConnectionWindow::loadConnections()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
||||
qRegisterMetaTypeStreamOperators<CANBus>();
|
||||
qRegisterMetaTypeStreamOperators<QList<CANBus>>();
|
||||
#endif
|
||||
|
||||
QSettings settings;
|
||||
|
||||
|
||||
+3
-1
@@ -30,8 +30,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
||||
qRegisterMetaTypeStreamOperators<QVector<QString>>();
|
||||
qRegisterMetaTypeStreamOperators<QVector<int>>();
|
||||
#endif
|
||||
|
||||
useHex = true;
|
||||
|
||||
@@ -178,7 +180,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
updateTimer.setInterval(250);
|
||||
updateTimer.start();
|
||||
|
||||
elapsedTime = new QTime;
|
||||
elapsedTime = new QElapsedTimer;
|
||||
elapsedTime->start();
|
||||
|
||||
isConnected = false;
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ private:
|
||||
DBCHandler *dbcHandler;
|
||||
QByteArray inputBuffer;
|
||||
QTimer updateTimer;
|
||||
QTime *elapsedTime;
|
||||
QElapsedTimer *elapsedTime;
|
||||
int framesPerSec;
|
||||
int rxFrames;
|
||||
bool inhibitFilterUpdate;
|
||||
|
||||
+16
-28
@@ -156,26 +156,8 @@ class QCPPolarGraph;
|
||||
|
||||
It provides QMetaObject-based reflection of its enums and flags via \a QCP::staticMetaObject.
|
||||
*/
|
||||
#ifndef Q_MOC_RUN
|
||||
namespace QCP {
|
||||
#else
|
||||
class QCP { // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace
|
||||
Q_GADGET
|
||||
Q_ENUMS(ExportPen)
|
||||
Q_ENUMS(ResolutionUnit)
|
||||
Q_ENUMS(SignDomain)
|
||||
Q_ENUMS(MarginSide)
|
||||
Q_FLAGS(MarginSides)
|
||||
Q_ENUMS(AntialiasedElement)
|
||||
Q_FLAGS(AntialiasedElements)
|
||||
Q_ENUMS(PlottingHint)
|
||||
Q_FLAGS(PlottingHints)
|
||||
Q_ENUMS(Interaction)
|
||||
Q_FLAGS(Interactions)
|
||||
Q_ENUMS(SelectionRectMode)
|
||||
Q_ENUMS(SelectionType)
|
||||
public:
|
||||
#endif
|
||||
Q_NAMESPACE
|
||||
|
||||
/*!
|
||||
Defines the different units in which the image resolution can be specified in the export
|
||||
@@ -318,6 +300,20 @@ enum SelectionType { stNone ///< The plottable is not selectable
|
||||
,stMultipleDataRanges ///< Any combination of data points/ranges can be selected
|
||||
};
|
||||
|
||||
Q_ENUM_NS(ExportPen)
|
||||
Q_ENUM_NS(ResolutionUnit)
|
||||
Q_ENUM_NS(SignDomain)
|
||||
Q_ENUM_NS(MarginSide)
|
||||
Q_FLAG_NS(MarginSides)
|
||||
Q_ENUM_NS(AntialiasedElement)
|
||||
Q_FLAG_NS(AntialiasedElements)
|
||||
Q_ENUM_NS(PlottingHint)
|
||||
Q_FLAG_NS(PlottingHints)
|
||||
Q_ENUM_NS(Interaction)
|
||||
Q_FLAG_NS(Interactions)
|
||||
Q_ENUM_NS(SelectionRectMode)
|
||||
Q_ENUM_NS(SelectionType)
|
||||
|
||||
/*! \internal
|
||||
|
||||
Returns whether the specified \a value is considered an invalid data value for plottables (i.e.
|
||||
@@ -386,15 +382,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
|
||||
Q_DECLARE_METATYPE(QCP::ExportPen)
|
||||
Q_DECLARE_METATYPE(QCP::ResolutionUnit)
|
||||
Q_DECLARE_METATYPE(QCP::SignDomain)
|
||||
Q_DECLARE_METATYPE(QCP::MarginSide)
|
||||
Q_DECLARE_METATYPE(QCP::AntialiasedElement)
|
||||
Q_DECLARE_METATYPE(QCP::PlottingHint)
|
||||
Q_DECLARE_METATYPE(QCP::Interaction)
|
||||
Q_DECLARE_METATYPE(QCP::SelectionRectMode)
|
||||
Q_DECLARE_METATYPE(QCP::SelectionType)
|
||||
//no need to use Q_DECLARE_METATYPE on enum since Q_ENUM_NS adds enum as metatype automatically
|
||||
|
||||
/* end of 'src/global.h' */
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define SNIFFERITEM_H
|
||||
|
||||
#include <QVariant>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
#include "can_structs.h"
|
||||
|
||||
struct fstCan
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
quint64 mCurrentTime;
|
||||
quint64 mCurrSeqVal;
|
||||
|
||||
QTime mTime;
|
||||
QElapsedTimer mTime;
|
||||
};
|
||||
|
||||
#endif // SNIFFERITEM_H
|
||||
|
||||
+10
-1
@@ -4,6 +4,9 @@
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
|
||||
#include <QtCore/QRandomGenerator>
|
||||
#endif
|
||||
|
||||
#include "connections/canconmanager.h"
|
||||
#include "helpwindow.h"
|
||||
@@ -234,7 +237,13 @@ void ScriptingWindow::createNewScript()
|
||||
|
||||
container = new ScriptContainer();
|
||||
|
||||
container->fileName = "UNNAMED_" + QString::number((qrand() % 10000)) + ".js";
|
||||
QString randomPart;
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
|
||||
randomPart = QString::number((qrand() % 10000));
|
||||
#else
|
||||
randomPart = QString::number((QRandomGenerator::global()->bounded(10000)));
|
||||
#endif
|
||||
container->fileName = "UNNAMED_" + randomPart + ".js";
|
||||
container->filePath = QString();
|
||||
container->scriptText = QString();
|
||||
container->setScriptWindow(this);
|
||||
|
||||
@@ -31,6 +31,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QDateTime>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDataStream>
|
||||
#include <QIODevice>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
|
||||
#include <QtCore/QRandomGenerator>
|
||||
#endif
|
||||
|
||||
SimpleCrypt::SimpleCrypt():
|
||||
m_key(0),
|
||||
@@ -38,7 +42,9 @@ SimpleCrypt::SimpleCrypt():
|
||||
m_protectionMode(ProtectionChecksum),
|
||||
m_lastError(ErrorNoError)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
|
||||
qsrand(uint(QDateTime::currentMSecsSinceEpoch() & 0xFFFF));
|
||||
#endif
|
||||
}
|
||||
|
||||
SimpleCrypt::SimpleCrypt(quint64 key):
|
||||
@@ -47,7 +53,9 @@ SimpleCrypt::SimpleCrypt(quint64 key):
|
||||
m_protectionMode(ProtectionChecksum),
|
||||
m_lastError(ErrorNoError)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
|
||||
qsrand(uint(QDateTime::currentMSecsSinceEpoch() & 0xFFFF));
|
||||
#endif
|
||||
splitKey();
|
||||
}
|
||||
|
||||
@@ -113,7 +121,11 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext)
|
||||
}
|
||||
|
||||
//prepend a random char to the string
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
|
||||
char randomChar = char(qrand() & 0xFF);
|
||||
#else
|
||||
char randomChar = char(QRandomGenerator::global()->bounded(256));
|
||||
#endif
|
||||
ba = randomChar + integrityProtection + ba;
|
||||
|
||||
int pos(0);
|
||||
|
||||
Reference in New Issue
Block a user