Handle no setting manager case

Can't save the fallback generated UUID for machine fingerprint if
the user of this stuff doesn't have a settings file.  Found this when
I noticed needed to initialize com for all the assignment clients
This commit is contained in:
David Kelly 2016-12-14 16:43:37 -08:00 committed by Seth Alves
parent fa9aef8b22
commit 1e66bcae1b

View file

@ -10,8 +10,13 @@
//
#include "FingerprintUtils.h"
#include <QDebug>
#include <SettingHandle.h>
#include <SettingManager.h>
#include <DependencyManager.h>
#ifdef Q_OS_WIN
#include <comdef.h>
#include <Wbemidl.h>
@ -171,6 +176,11 @@ QUuid FingerprintUtils::getMachineFingerprint() {
// any errors in getting the string
QUuid uuid(uuidString);
if (uuid == QUuid()) {
// if you cannot read a fallback key cuz we aren't saving them, just generate one for
// this session and move on
if (DependencyManager::get<Setting::Manager>().isNull()) {
return QUuid::createUuid();
}
// read fallback key (if any)
Settings settings;
uuid = QUuid(settings.value(FALLBACK_FINGERPRINT_KEY).toString());