diff options
author | saturneric <[email protected]> | 2024-01-12 15:08:38 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-12 15:08:38 +0000 |
commit | 6983b5c1dd82d159236ebd06cf17f071cc9c1ee9 (patch) | |
tree | fc53f790e33546320b2ecd306a1a9ade6fbdfe7a /src/core/module/GlobalModuleContext.cpp | |
parent | fix: slove a heap-use-after-free issue (diff) | |
download | GpgFrontend-6983b5c1dd82d159236ebd06cf17f071cc9c1ee9.tar.gz GpgFrontend-6983b5c1dd82d159236ebd06cf17f071cc9c1ee9.zip |
refactor: remove boost and use QString instead of std::filesystem::path
Diffstat (limited to 'src/core/module/GlobalModuleContext.cpp')
-rw-r--r-- | src/core/module/GlobalModuleContext.cpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/core/module/GlobalModuleContext.cpp b/src/core/module/GlobalModuleContext.cpp index cac3dfbb..16650c96 100644 --- a/src/core/module/GlobalModuleContext.cpp +++ b/src/core/module/GlobalModuleContext.cpp @@ -28,8 +28,6 @@ #include "GlobalModuleContext.h" -#include <boost/date_time.hpp> -#include <boost/random.hpp> #include <set> #include <unordered_map> #include <unordered_set> @@ -46,11 +44,7 @@ namespace GpgFrontend::Module { class GlobalModuleContext::Impl { public: - explicit Impl() - : random_gen_( - (boost::posix_time::microsec_clock::universal_time() - - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))) - .total_milliseconds()) { + explicit Impl() { // Initialize acquired channels with default values. acquired_channel_.insert(kGpgFrontendDefaultChannel); acquired_channel_.insert(kGpgFrontendNonAsciiChannel); @@ -299,16 +293,13 @@ class GlobalModuleContext::Impl { module_events_table_; std::set<int> acquired_channel_; - boost::random::mt19937 random_gen_; TaskRunnerPtr default_task_runner_; auto acquire_new_unique_channel() -> int { - boost::random::uniform_int_distribution<> dist(1, 65535); - - int random_channel = dist(random_gen_); + int random_channel = QRandomGenerator::global()->bounded(65535); // Ensure the acquired channel is unique. while (acquired_channel_.find(random_channel) != acquired_channel_.end()) { - random_channel = dist(random_gen_); + random_channel = QRandomGenerator::global()->bounded(65535); } // Add the acquired channel to the set. |