Added searching to DBC window to make it easier to find messages. Replaced deprecated random number calls with new method.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "ui_fuzzingwindow.h"
|
||||
#include "utility.h"
|
||||
#include <QDebug>
|
||||
#include <QRandomGenerator>
|
||||
#include "mainwindow.h"
|
||||
#include "helpwindow.h"
|
||||
#include "connections/canconmanager.h"
|
||||
@@ -250,12 +251,12 @@ void FuzzingWindow::calcNextID()
|
||||
if (rangeIDSelect)
|
||||
{
|
||||
int range = endID - startID;
|
||||
if (range != 0) currentID = startID + qrand() % range;
|
||||
if (range != 0) currentID = startID + QRandomGenerator::global()->bounded(range);
|
||||
else currentID = startID;
|
||||
}
|
||||
else //IDs by filter so pick a random selected ID from the filter list
|
||||
{
|
||||
currentIdx = qrand() % selectedIDs.length();
|
||||
currentIdx = QRandomGenerator::global()->bounded(selectedIDs.length());
|
||||
currentID = selectedIDs[currentIdx];
|
||||
}
|
||||
}
|
||||
@@ -277,7 +278,7 @@ void FuzzingWindow::calcNextBitPattern()
|
||||
thisBit = bitGrid[byt * 8 + bit];
|
||||
if (thisBit == 1)
|
||||
{
|
||||
if ((qrand() % 2) == 1) currentBytes[byt] |= (1 << bit);
|
||||
if ((QRandomGenerator::global()->bounded(2)) == 1) currentBytes[byt] |= (1 << bit);
|
||||
}
|
||||
if (thisBit == 2) currentBytes[byt] |= (1 << bit);
|
||||
}
|
||||
@@ -391,12 +392,12 @@ void FuzzingWindow::toggleFuzzing()
|
||||
if (rangeIDSelect)
|
||||
{
|
||||
int range = endID - startID;
|
||||
if (range != 0) currentID = startID + qrand() % range;
|
||||
if (range != 0) currentID = startID + QRandomGenerator::global()->bounded(range);
|
||||
else currentID = startID;
|
||||
}
|
||||
else //IDs by filter so pick a random selected ID from the filter list
|
||||
{
|
||||
currentIdx = qrand() % selectedIDs.length();
|
||||
currentIdx = QRandomGenerator::global()->bounded(selectedIDs.length());
|
||||
currentID = selectedIDs[currentIdx];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "newgraphdialog.h"
|
||||
#include "ui_newgraphdialog.h"
|
||||
#include <QColorDialog>
|
||||
#include <QRandomGenerator>
|
||||
#include "utility.h"
|
||||
#include "helpwindow.h"
|
||||
|
||||
@@ -15,13 +16,9 @@ NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->colorSwatch, SIGNAL(clicked(bool)), this, SLOT(colorSwatchClick()));
|
||||
connect(ui->btnAddGraph, SIGNAL(clicked(bool)), this, SLOT(addButtonClicked()));
|
||||
|
||||
// Seed the random generator with current time
|
||||
QTime time = QTime::currentTime();
|
||||
qsrand((uint)time.msec());
|
||||
|
||||
QPalette p = ui->colorSwatch->palette();
|
||||
//using 160 instead of 255 so that colors are always at least a little dark
|
||||
p.setColor(QPalette::Button, QColor(qrand() % 160,qrand() % 160,qrand() % 160));
|
||||
p.setColor(QPalette::Button, QColor(QRandomGenerator::global()->bounded(160),QRandomGenerator::global()->bounded(160), QRandomGenerator::global()->bounded(160)));
|
||||
ui->colorSwatch->setPalette(p);
|
||||
|
||||
connect(ui->cbMessages, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSignals(int)));
|
||||
|
||||
Reference in New Issue
Block a user