diff --git a/src/MeasurementComplexItem/geometry/MeasurementArea.cc b/src/MeasurementComplexItem/geometry/MeasurementArea.cc index 4f9a4fa952b8318a5000a0e5ce89a9ee88114a58..e2c2bca9e42541e7a7775ecac45efb56286500d8 100644 --- a/src/MeasurementComplexItem/geometry/MeasurementArea.cc +++ b/src/MeasurementComplexItem/geometry/MeasurementArea.cc @@ -19,7 +19,7 @@ #define MAX_TILES 1000 #endif -QString randomId(); +QString randomId(std::size_t length = 10); using namespace geometry; namespace trans = bg::strategy::transform; @@ -726,13 +726,24 @@ bool getTiles(const FPolygon &area, Length tileHeight, Length tileWidth, return true; } -QString randomId() { - std::srand(std::time(nullptr)); - std::int64_t r = 0; - - for (int i = 0; i < 10; ++i) { - r ^= std::rand(); +QString randomId(std::size_t length) { + static const QString values( + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); + static std::uint64_t counter = 0; + static auto firstCall = std::chrono::high_resolution_clock::now(); + + auto delta = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - firstCall) + .count(); + + std::srand((unsigned int)delta ^ counter); + QString str; + for (int i = 0; i < length; ++i) { + int index = std::rand() % values.length(); + QChar c = values.at(index); + str.append(c); } - return QString::number(r); + ++counter; + return str; }