here is my code:

Qt Code:
  1. QSharedMemory numofallplayers;
  2.  
  3. void sesman::run()
  4. {
  5. numofallplayers.setKey("numofallplayers");
  6. numofallplayers.create(sizeof(qint64), QSharedMemory::ReadWrite);
  7.  
  8. qDebug() << "session manager thread starts from" << QThread::currentThread();
  9. qDebug() << "seting total players to zero";
  10. sesman::SetNumOfAllPlayers(0);
  11. qDebug() << "num of players total: " << sesman::GetNumOfAllPlayers(); //just to check
  12. .
  13. .
  14. .
  15. cleanup();
  16. }
  17.  
  18.  
  19. void sesman::SetNumOfAllPlayers(qint64 totalplayers)
  20. {
  21. if(numofallplayers.isAttached()){
  22. numofallplayers.detach();
  23. }
  24. if(!numofallplayers.attach(QSharedMemory::ReadWrite)){
  25. //some error
  26. qDebug() << "attach numofallplayers failed" << numofallplayers.errorString();
  27. }
  28. numofallplayers.lock();
  29. qint64* totalpl = (qint64*)numofallplayers.data();
  30. *totalpl = totalplayers;
  31. numofallplayers.unlock();
  32. if(!numofallplayers.detach())
  33. qDebug() << "unable to detach";
  34. }
To copy to clipboard, switch view to plain text mode 

and i get following error

seting total players to zero
attach numofallplayers failed "QSharedMemory::handle:: UNIX key file doesn't exist"
The program has unexpectedly finished.

Can someone help? what is wrong with my code?

thanks a lot for any help...