Skip to content

Commit

Permalink
fix usage of seed_seq
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulh committed Nov 7, 2017
1 parent a33c282 commit 5eef950
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scripts/ci/osx/after_success.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ VERSION="$(get_version .)"
#Only build if the commit we are building is for the last tag
if [ "$(git rev-list -n 1 $VERSION)" != "$(cat .git/HEAD)" ]; then
echo "Not uploading package"
return 0
# return 0
fi

QTDIR="/usr/local/opt/qt5"
Expand Down
8 changes: 3 additions & 5 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,23 +352,21 @@ QString Common::maskLog(const QString &rawJson)
static std::vector<qint64> mpRngIntegers;
static std::random_device rngDevice;

std::seed_seq Common::getRngSeed()
std::vector<qint64> Common::getRngSeed()
{
if (mpRngIntegers.empty())
{
std::vector<qint64> ints = {rngDevice(), rngDevice(), rngDevice(), rngDevice(),
rngDevice(), rngDevice(), rngDevice(), rngDevice(),
std::chrono::system_clock::now().time_since_epoch().count()};
std::seed_seq sequence(ints.begin(), ints.end());
return sequence;
return ints;
}
else
{
std::vector<qint64> ints = mpRngIntegers;
ints.push_back(rngDevice());
ints.push_back(std::chrono::system_clock::now().time_since_epoch().count());
std::seed_seq sequence(ints.begin(), ints.end());
return sequence;
return ints;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Common
//mask log by removing passwords and data from log
static QString maskLog(const QString &rawJson);

static std::seed_seq getRngSeed();
static std::vector<qint64> getRngSeed();
static void updateSeed(std::vector<qint64> &newInts);

typedef enum
Expand Down
3 changes: 2 additions & 1 deletion src/PasswordLineEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ void PasswordLineEdit::setPasswordVisible(bool visible)
PasswordOptionsPopup::PasswordOptionsPopup(QWidget* parent):
QFrame(parent, Qt::Popup)
{
auto seed = Common::getRngSeed();
auto iseed = Common::getRngSeed();
std::seed_seq seed(iseed.begin(), iseed.end());
m_random_generator.seed(seed);

setFrameShadow(QFrame::Plain);
Expand Down

0 comments on commit 5eef950

Please sign in to comment.