aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItay Grudev <itay@grudev.com>2016-08-18 18:28:57 +0100
committerItay Grudev <itay@grudev.com>2016-08-18 18:28:57 +0100
commit5d867d77a5d38f024eca63ab9a470e64be66df53 (patch)
tree3610d12c2f0eb298a1bc925f07054a9e11585666
parentImproved documentation styling. Added HRs between API members. (diff)
downloadsingleapplication-5d867d77a5d38f024eca63ab9a470e64be66df53.tar.xz
Fix bug (and compiler error) on Windows - wchar username support
-rw-r--r--singleapplication.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/singleapplication.cpp b/singleapplication.cpp
index 6b3b85b..4fba93c 100644
--- a/singleapplication.cpp
+++ b/singleapplication.cpp
@@ -68,12 +68,13 @@ void SingleApplicationPrivate::genBlockServerName( int timeout )
// User level block requires a user specific data in the hash
if( options & SingleApplication::Mode::User ) {
#ifdef Q_OS_WIN
- char username[UNLEN + 1];
+ wchar_t username [ UNLEN + 1 ];
// Specifies size of the buffer on input
- DWORD usernameLength = sizeof( username );
+ DWORD usernameLength = UNLEN + 1;
if( GetUserName( username, &usernameLength ) ) {
- // usernameLength includes the null terminating character
- appData.addData( username, usernameLength - 1 );
+ char buffer[512];
+ size_t length = wcstombs( buffer, username, 512 );
+ appData.addData( buffer, length );
} else {
appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() );
}