QSharedMemory won't attach
Hello,
This is happening both with qt examples and my own sample code. Specifically, when I execute this:
Code:
QSharedMemory* mem = new QSharedMemory("testkey");
mem->create(sizeof(int));
if (mem->attach())
qDebug() << "Successful attach()";
else
qDebug() << "attach() failed, code " << mem->error() << ", " << mem->errorString();
I get this:
Quote:
attach() failed, code 0 , ""
The same thing happens with the examples (examples/ipc/sharedmemory and another one from Nokia that displays images). The attach fails yet no error flag is thrown. Moreover this happens on Max 10.5, Windows XP, and Ubuntu 9.10; I'm using Qt 4.5.3. Does anybody know what's going on? Thank you--
Matt
Re: QSharedMemory won't attach
Quite strange!
mem->error() return 0 from the docs it means:
QSharedMemory::NoError
check your if statement ( the one you posted look good to me but it seems the problem is there...... :confused:)
Good Luck
ops maybe create already attach the shared memory?
Re: QSharedMemory won't attach
Quote:
ops maybe create already attach the shared memory?
the docs say: yes, create does attach (see QSharedMemory::create())
Re: QSharedMemory won't attach
Thanks guys! Running QSharedMemory::isAttached() after creation returned true so I think that was my problem (doh!). The Qt IPC dialog example does in fact work just fine, I wasn't running it correctly, however this one doesn't:
http://www.forum.nokia.com/info/sw.n...y_Example.html
--haven't figured out why. Possibly for a completely different reason though. Anyway, thanks--
Matt