From a8d3aad97a4895b61b6cddd733f0cea4f82f38b1 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Tue, 29 Mar 2016 18:24:16 -0400 Subject: [PATCH] Add darwin-specific shared mem file open and close in RemoteGraphicsView.py to account for lack of mremap on platform. --- pyqtgraph/widgets/RemoteGraphicsView.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pyqtgraph/widgets/RemoteGraphicsView.py b/pyqtgraph/widgets/RemoteGraphicsView.py index 75ce90b0..85f5556a 100644 --- a/pyqtgraph/widgets/RemoteGraphicsView.py +++ b/pyqtgraph/widgets/RemoteGraphicsView.py @@ -77,6 +77,10 @@ class RemoteGraphicsView(QtGui.QWidget): if sys.platform.startswith('win'): self.shmtag = newfile ## on windows, we create a new tag for every resize self.shm = mmap.mmap(-1, size, self.shmtag) ## can't use tmpfile on windows because the file can only be opened once. + elif sys.platform == 'darwin': + self.shmFile.close() + self.shmFile = open(self._view.shmFileName(), 'r') + self.shm = mmap.mmap(self.shmFile.fileno(), size, mmap.MAP_SHARED, mmap.PROT_READ) else: self.shm = mmap.mmap(self.shmFile.fileno(), size, mmap.MAP_SHARED, mmap.PROT_READ) self.shm.seek(0) @@ -193,6 +197,13 @@ class Renderer(GraphicsView): ## it also says (sometimes) 'access is denied' if we try to reuse the tag. self.shmtag = "pyqtgraph_shmem_" + ''.join([chr((random.getrandbits(20)%25) + 97) for i in range(20)]) self.shm = mmap.mmap(-1, size, self.shmtag) + elif sys.platform == 'darwin': + self.shm.close() + self.shmFile.close() + self.shmFile = tempfile.NamedTemporaryFile(prefix='pyqtgraph_shmem_') + self.shmFile.write(b'\x00' * (size + 1)) + self.shmFile.flush() + self.shm = mmap.mmap(self.shmFile.fileno(), size, mmap.MAP_SHARED, mmap.PROT_WRITE) else: self.shm.resize(size)