Results 1 to 4 of 4

Thread: QSharedMemory won't attach

  1. #1
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QSharedMemory won't attach

    Hello,

    This is happening both with qt examples and my own sample code. Specifically, when I execute this:

    Qt Code:
    1. QSharedMemory* mem = new QSharedMemory("testkey");
    2. mem->create(sizeof(int));
    3. if (mem->attach())
    4. qDebug() << "Successful attach()";
    5. else
    6. qDebug() << "attach() failed, code " << mem->error() << ", " << mem->errorString();
    To copy to clipboard, switch view to plain text mode 

    I get this:

    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

  2. #2
    Join Date
    Nov 2008
    Location
    Italy
    Posts
    16
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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...... )

    Good Luck


    ops maybe create already attach the shared memory?

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSharedMemory won't attach

    ops maybe create already attach the shared memory?
    the docs say: yes, create does attach (see QSharedMemory::create())

  4. #4
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

Similar Threads

  1. SQLITE ATTACH database
    By drescherjm in forum Qt Programming
    Replies: 8
    Last Post: 9th December 2009, 07:25
  2. Replies: 3
    Last Post: 29th October 2009, 21:13
  3. QSharedMemory in processes from different accounts
    By Ursa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2009, 09:50
  4. Open outlook attach (.txt) in Qtextedit
    By assismvla in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2008, 15:45
  5. Cannot attach region manager
    By bhm in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2006, 12:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.