mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Rewrite horrible type casting pointer magic with shifts
Why would you generate that random number byte by byte, anyway ?
This commit is contained in:
parent
3de63c0061
commit
007a10346d
|
@ -157,11 +157,11 @@ void PrivacyForm::generateRandomNospam()
|
|||
QTime time = QTime::currentTime();
|
||||
qsrand((uint)time.msec());
|
||||
|
||||
uint8_t newNospam[4];
|
||||
uint32_t newNospam;
|
||||
for (int i = 0; i < 4; i++)
|
||||
newNospam[i] = qrand() % 256;
|
||||
newNospam = (newNospam<<8) + (qrand() % 256); // Generate byte by byte. For some reason.
|
||||
|
||||
Core::getInstance()->setNospam(*reinterpret_cast<uint32_t*>(newNospam));
|
||||
Core::getInstance()->setNospam(newNospam);
|
||||
bodyUI->nospamLineEdit->setText(Core::getInstance()->getSelfId().noSpam);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user