Skip to content

Instantly share code, notes, and snippets.

@computerquip
Created July 18, 2023 04:02
Show Gist options
  • Save computerquip/e90261e4a4477975e2d1b93004fb212b to your computer and use it in GitHub Desktop.
Save computerquip/e90261e4a4477975e2d1b93004fb212b to your computer and use it in GitHub Desktop.
Some random guid patch I have for some reason
commit 9eb5bf4515aba998e215049baf62c0be153eb70a
Author: Zachary Lund <admin@computerquip.com>
Date: Sun Jul 16 17:17:41 2023 -0500
UI: Use QUuid for uuid generation
diff --git a/UI/update/shared-update.cpp b/UI/update/shared-update.cpp
index ef1b0b075..cfacda50f 100644
--- a/UI/update/shared-update.cpp
+++ b/UI/update/shared-update.cpp
@@ -127,18 +127,6 @@ try {
/* ------------------------------------------------------------------------ */
-void GenerateGUID(std::string &guid)
-{
- const char alphabet[] = "0123456789abcdef";
- QRandomGenerator *rng = QRandomGenerator::system();
-
- guid.resize(40);
-
- for (size_t i = 0; i < 40; i++) {
- guid[i] = alphabet[rng->bounded(0, 16)];
- }
-}
-
std::string GetProgramGUID()
{
static std::mutex m;
@@ -147,18 +135,17 @@ std::string GetProgramGUID()
/* NOTE: this is an arbitrary random number that we use to count the
* number of unique OBS installations and is not associated with any
* kind of identifiable information */
- const char *pguid =
+ QString guid =
config_get_string(GetGlobalConfig(), "General", "InstallGUID");
- std::string guid;
- if (pguid)
- guid = pguid;
- if (guid.empty()) {
- GenerateGUID(guid);
+ if (guid.isEmpty() ) {
+ guid = QUuid::createUuid();
+
+ if (!guid.isEmpty()) {
- if (!guid.empty())
config_set_string(GetGlobalConfig(), "General",
- "InstallGUID", guid.c_str());
+ "InstallGUID", guid.toStdString().c_str());
+ }
}
return guid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment