diff options
Diffstat (limited to 'src/corelib/kernel/qsharedmemory_win.cpp')
-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; |