QSysInfo: use QString::data() instead of const_cast
Change-Id: Ib95cdc4c428c429c8965e32b2fd0be31944b4d2d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
525aff168e
commit
a127aea57b
@ -963,11 +963,11 @@ QString QSysInfo::machineHostName()
|
||||
hostName.resize(512);
|
||||
unsigned long len = hostName.size();
|
||||
BOOL res = GetComputerNameEx(ComputerNameDnsHostname,
|
||||
reinterpret_cast<wchar_t *>(const_cast<quint16 *>(hostName.utf16())), &len);
|
||||
reinterpret_cast<wchar_t *>(hostName.data()), &len);
|
||||
if (!res && len > 512) {
|
||||
hostName.resize(len - 1);
|
||||
GetComputerNameEx(ComputerNameDnsHostname,
|
||||
reinterpret_cast<wchar_t *>(const_cast<quint16 *>(hostName.utf16())), &len);
|
||||
GetComputerNameEx(ComputerNameDnsHostname, reinterpret_cast<wchar_t *>(hostName.data()),
|
||||
&len);
|
||||
}
|
||||
hostName.truncate(len);
|
||||
return hostName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user