Implement sessionId/key generation on Windows

sessionId and sessionKey generation on Windows was lost in the
transition of Qt 4 to Qt 5. During the reimplementation of the
QSessionManagement feature, that part has been missed. This patch fixes
that.

Based on Qt 4

[ChangeLog][QtGui][Windows] Fixed a regression where both
sessionId/sessionKey were empty

Task-number: QTBUG-47690
Change-Id: I17b5fbee9d0979d292d30b94b3a2cc3107fc54fd
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Samuel Gaist 2015-08-17 09:39:46 +02:00
parent 9c71f55ef9
commit 847d5d1309

View File

@ -99,6 +99,9 @@
#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
# include <QtCore/qt_windows.h>
# include <QtCore/QLibraryInfo>
# if defined(Q_OS_WINPHONE)
# include <Objbase.h>
# endif
#endif // Q_OS_WIN && !Q_OS_WINCE
#include <ctype.h>
@ -1232,6 +1235,16 @@ void QGuiApplicationPrivate::init()
#ifndef QT_NO_SESSIONMANAGER
QString session_id;
QString session_key;
# if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
wchar_t guidstr[40];
GUID guid;
CoCreateGuid(&guid);
StringFromGUID2(guid, guidstr, 40);
session_id = QString::fromWCharArray(guidstr);
CoCreateGuid(&guid);
StringFromGUID2(guid, guidstr, 40);
session_key = QString::fromWCharArray(guidstr);
# endif
#endif
int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) {