summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qsharedmemory_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qsharedmemory_unix.cpp')
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index fc0a4386cd..b30117f6c1 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -198,7 +198,7 @@ bool QSharedMemoryPrivate::create(int size)
}
// create
- if (-1 == shmget(handle(), size, 0666 | IPC_CREAT | IPC_EXCL)) {
+ if (-1 == shmget(unix_key, size, 0666 | IPC_CREAT | IPC_EXCL)) {
QString function = QLatin1String("QSharedMemory::create");
switch (errno) {
case EINVAL:
@@ -219,10 +219,7 @@ bool QSharedMemoryPrivate::create(int size)
bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
{
// grab the shared memory segment id
- if (!handle())
- return false;
-
- int id = shmget(handle(), 0, (mode == QSharedMemory::ReadOnly ? 0444 : 0660));
+ int id = shmget(unix_key, 0, (mode == QSharedMemory::ReadOnly ? 0444 : 0660));
if (-1 == id) {
setErrorString(QLatin1String("QSharedMemory::attach (shmget)"));
return false;
@@ -264,12 +261,11 @@ bool QSharedMemoryPrivate::detach()
return false;
}
memory = 0;
+ size = 0;
// Get the number of current attachments
- if (!handle())
- return false;
- int id = shmget(handle(), 0, 0444);
- unix_key = 0;
+ int id = shmget(unix_key, 0, 0444);
+ cleanHandle();
struct shmid_ds shmid_ds;
if (0 != shmctl(id, IPC_STAT, &shmid_ds)) {