From 8f273f53ab7138baa5fa8a7a9bc8bfa145a55000 Mon Sep 17 00:00:00 2001 From: John David Reaver Date: Wed, 15 Oct 2014 06:16:40 -0700 Subject: [PATCH] Fix memory leak in GLScatterPlotItem Fixes #103. If a ScatterPlotItem was removed from a plot and added again, glGenTetures was called again unneccesarily. Each time it is called, it eats up a little more space. --- pyqtgraph/opengl/items/GLScatterPlotItem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/opengl/items/GLScatterPlotItem.py b/pyqtgraph/opengl/items/GLScatterPlotItem.py index 6cfcc6aa..dc4b298a 100644 --- a/pyqtgraph/opengl/items/GLScatterPlotItem.py +++ b/pyqtgraph/opengl/items/GLScatterPlotItem.py @@ -66,7 +66,8 @@ class GLScatterPlotItem(GLGraphicsItem): #print pData.shape, pData.min(), pData.max() pData = pData.astype(np.ubyte) - self.pointTexture = glGenTextures(1) + if getattr(self, "pointTexture", None) is None: + self.pointTexture = glGenTextures(1) glActiveTexture(GL_TEXTURE0) glEnable(GL_TEXTURE_2D) glBindTexture(GL_TEXTURE_2D, self.pointTexture)