Don't use explicit memory management

And avoid dangling pointers.
This commit is contained in:
Chocobo1 2022-03-23 15:27:47 +08:00
parent 8a708fd97e
commit bbd936fdfa
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
9 changed files with 28 additions and 36 deletions

View file

@ -31,6 +31,8 @@
#include <optional>
#ifdef Q_OS_WIN
#include <memory>
#include <windows.h>
#include <powrprof.h>
#include <Shlobj.h>
@ -393,7 +395,7 @@ QString Utils::Misc::getUserIDString()
const int UNLEN = 256;
WCHAR buffer[UNLEN + 1] = {0};
DWORD buffer_len = sizeof(buffer) / sizeof(*buffer);
if (GetUserNameW(buffer, &buffer_len))
if (::GetUserNameW(buffer, &buffer_len))
uid = QString::fromWCharArray(buffer);
#else
uid = QString::number(getuid());