fix: seed PRNG so code/math challenges change on every ring #1
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/code-challenge-not-random"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The dismiss challenge code (4-digit code) and math problem were not actually random — they produced the same value every time.
Root cause
qrand()was called inbeginRinging()to generate the challenge, butqsrand()was never called to seed the PRNG. On this Qt (older than 5.7),qrand()defaults to a deterministic seed, so every alarm ring presented the same four-digit code and the same math problem — defeating the entire purpose of the dismiss challenge.Fix
Seed
qrand()withQDateTime::currentMSecsSinceEpoch()before each challenge generation inbeginRinging(). Each ringer is a fresh process launched by timed, so per-ring seeding is sufficient and avoids any global init-order dependency (AGENTS.md landmine #7).Added seeding in both the
codeandmathchallenge branches.Version bumped to 0.0.15 per the build-iteration policy.
Files changed
app/src/alarmcontroller.cpp— addedqsrand()calls beforeqrand()usageapp/app.pro— version bump 0.0.14 → 0.0.15rpm/harbour-heratys52.spec— version bump 0.0.14 → 0.0.15