diff options
author | Andrew Knight <andrew.knight@digia.com> | 2013-09-13 12:01:16 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-20 13:54:04 +0200 |
commit | 89f299201df9c44d118f3effcd2ea919c8159aec (patch) | |
tree | b77ad74ec14118217c4a4e790e8c7aa892158438 /src/corelib | |
parent | 95e0da216f0a94d5b1bfa7aec77d20fe5ba01f55 (diff) |
WinRT: Shared memory support
WinRT supports in-memory file mapping via CreateFileMappingFromApp. This
is unimplemented on Windows Phone.
Change-Id: Ic5692e501cd2fe9e1337829bdeb933fccc804abe
Done-with: Andrew Knight
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qsharedmemory_win.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp index a88d2c858b..b00434977b 100644 --- a/src/corelib/kernel/qsharedmemory_win.cpp +++ b/src/corelib/kernel/qsharedmemory_win.cpp @@ -105,12 +105,17 @@ HANDLE QSharedMemoryPrivate::handle() errorString = QSharedMemory::tr("%1: unable to make key").arg(function); return 0; } -#ifndef Q_OS_WINCE - hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16()); -#else +#if defined(Q_OS_WINPHONE) + Q_UNIMPLEMENTED(); + hand = 0; +#elif defined(Q_OS_WINRT) + hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, (PCWSTR)nativeKey.utf16()); +#elif defined(Q_OS_WINCE) // This works for opening a mapping too, but always opens it with read/write access in // attach as it seems. hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)nativeKey.utf16()); +#else + hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16()); #endif if (!hand) { setErrorString(function); @@ -141,7 +146,14 @@ bool QSharedMemoryPrivate::create(int size) } // Create the file mapping. +#if defined(Q_OS_WINPHONE) + Q_UNIMPLEMENTED(); + hand = 0; +#elif defined(Q_OS_WINRT) + hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, size, (PCWSTR)nativeKey.utf16()); +#else hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)nativeKey.utf16()); +#endif setErrorString(function); // hand is valid when it already exists unlike unix so explicitly check @@ -155,7 +167,14 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode) { // Grab a pointer to the memory block int permissions = (mode == QSharedMemory::ReadOnly ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS); +#if defined(Q_OS_WINPHONE) + Q_UNIMPLEMENTED(); + memory = 0; +#elif defined(Q_OS_WINRT) + memory = (void *)MapViewOfFileFromApp(handle(), permissions, 0, 0); +#else memory = (void *)MapViewOfFile(handle(), permissions, 0, 0, 0); +#endif if (0 == memory) { setErrorString(QLatin1String("QSharedMemory::attach")); cleanHandle(); @@ -179,10 +198,15 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode) bool QSharedMemoryPrivate::detach() { // umap memory +#if defined(Q_OS_WINPHONE) + Q_UNIMPLEMENTED(); + return false; +#else if (!UnmapViewOfFile(memory)) { setErrorString(QLatin1String("QSharedMemory::detach")); return false; } +#endif memory = 0; size = 0; |