produktdotestow
18th November 2010, 20:11
hi,
i have small (i hope it's small) problem.
at first i run process1 and after - process2.
process1 code:
QSharedMemory sharedMemory("foobar");
sharedMemory.create(1024);
sharedMemory.lock();
QString *to = (QString*)sharedMemory.data();
QString *text = new QString("hello world");
memcpy(to, text, sizeof(*text));
sharedMemory.unlock();
process2 code:
QSharedMemory sharedMemory("foobar");
sharedMemory.attach();
sharedMemory.lock();
QString *to = (QString*)sharedMemory.data();
ui->plainTextEdit->setPlainText(*to);
sharedMemory.unlock();
this code makes process2 crash.
what's wrong with it?
thanks.
i have small (i hope it's small) problem.
at first i run process1 and after - process2.
process1 code:
QSharedMemory sharedMemory("foobar");
sharedMemory.create(1024);
sharedMemory.lock();
QString *to = (QString*)sharedMemory.data();
QString *text = new QString("hello world");
memcpy(to, text, sizeof(*text));
sharedMemory.unlock();
process2 code:
QSharedMemory sharedMemory("foobar");
sharedMemory.attach();
sharedMemory.lock();
QString *to = (QString*)sharedMemory.data();
ui->plainTextEdit->setPlainText(*to);
sharedMemory.unlock();
this code makes process2 crash.
what's wrong with it?
thanks.