i got following code and it looks like due to this code application crash (but still not sure, coz app is multithreaded)...

code Code:
  1. void simplex_user::user_to_mem()
  2. {
  3. if(!usershm.isAttached())
  4. usershm.attach(QSharedMemory::ReadWrite);
  5. QByteArray usercache;
  6. QDataStream ucd(&usercache, QIODevice::ReadWrite);
  7. usercache.clear();
  8. usercache.resize(44+1);
  9. ucd.device()->seek(0);
  10.  
  11. ucd << (quint8)this->status << (quint8)this->speed << (quint8)this->playernum // 0 1 2
  12. << (quint8)this->lookat << (quint8)this->key1 << (quint8)this->key2 // 3 4 5
  13. << (quint8)this->gotpowerup1 << (quint8)this->gotpowerup2 // 6 7
  14. << (qint8)this->yoffset << (qint8)this->xoffset << (quint16)this->pos // 8 9 10-11
  15. << (quint64)this->score << (quint64)this->adminkey << (quint64)this->playerid // 12-19 20-27 28-35
  16. << (quint64)this->achievements << (quint8)this->flags; // 36-43 44
  17. usershm.lock();
  18. char *to = (char*)usershm.data();
  19. const char *from = this->data.data();
  20. memcpy(to, from, qMin(usershm.size(), usershm.size()));
  21. usershm.unlock();
  22.  
  23.  
  24. }
  25.  
  26. void simplex_user::mem_to_user()
  27. {
  28. bool ok;
  29. QByteArray usercache;
  30. usercache.resize(44+1);
  31.  
  32. if(!usershm.isAttached())
  33. usershm.attach(QSharedMemory::ReadWrite);
  34. usershm.lock();
  35. usercache = QByteArray((char*)usershm.constData(), usershm.size()+1);
  36. this->data=usercache;
  37. usershm.unlock();
  38. this->status=usercache.mid(0,1).toHex().toUInt(&ok, 16);
  39. this->speed=usercache.mid(1,1).toHex().toUInt(&ok, 16);
  40. this->playernum=usercache.mid(2,1).toHex().toUInt(&ok, 16);
  41. this->lookat=usercache.mid(3,1).toHex().toUInt(&ok, 16);
  42. this->key1=usercache.mid(4,1).toHex().toUInt(&ok, 16);
  43. this->key2=usercache.mid(5,1).toHex().toUInt(&ok, 16);
  44. this->gotpowerup1=usercache.mid(6,1).toHex().toUInt(&ok, 16);
  45. this->gotpowerup2=usercache.mid(7,1).toHex().toUInt(&ok, 16);
  46. this->yoffset=usercache.mid(8,1).toHex().toUInt(&ok, 16);
  47. this->xoffset=usercache.mid(9,1).toHex().toUInt(&ok, 16);
  48. this->pos=usercache.mid(10,2).toHex().toUShort(&ok, 16);
  49. this->score=usercache.mid(12,8).toHex().toULongLong(&ok, 16);
  50. this->adminkey=usercache.mid(20,8).toHex().toULongLong(&ok, 16);
  51. this->playerid=usercache.mid(28,8).toHex().toULongLong(&ok, 16);
  52. this->achievements=usercache.mid(36,8).toHex().toULongLong(&ok, 16);
  53. this->flags=usercache.mid(44,8).toHex().toULongLong(&ok, 16);
  54. }
To copy to clipboard, switch view to plain text mode 

is anything wrong with this code?