Hi, I encountered the same problem back when Alexandre asked the same question. This is the workaround that I've been using:
CLIB = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c')) shared_memory.lock() try: CLIB.memcpy(int(shared_memory.data()), data_bytes, data_len) finally: shared_memory.unlock() It works on both Mac and Windows. Thanks, Yao On Mon, Nov 1, 2010 at 3:00 PM, Hans-Peter Jansen <h...@urpla.net> wrote: > Hi Phil, > > end of July last year, Alexandre Raczynski asked about accessing > QSharedMemory, and you replied, that: > > mutable_data = buffer(sharedMemory.data()) > > ...should give _write_ access to the memory. > > Hmm, not here: > > $ python > Python 2.6 (r26:66714, Mar 30 2010, 00:30:21) > [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> from PyQt4 import QtCore >>>> >>>> shmem = QtCore.QSharedMemory("xxx") >>>> shmem.create(10) > True >>>> shmem.lock() > True >>>> b = buffer(shmem.data()) >>>> repr(b) > '<read-only buffer for 0xb74a37a0, size -1, offset 0 at 0xb6c0f9a0>' >>>> b = buffer(shmem.data(), 0, 10) >>>> repr(b) > '<read-only buffer for 0xb74a3710, size 10, offset 0 at 0xb6c0f9c0>' >>>> > > Both attempts to create a buffer object resulted in read-only buffers, > that refuse getting modified. I must be doing something wrong, but > there's not much room left for manoeuvring.. > > Pete > > python: 2.6 > sip: 4.12-snapshot-12acbffd0085 > qt4: 4.7.0 > pyqt4: 4.8.1 > _______________________________________________ > PyQt mailing list p...@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt