Skip to content

Commit 9d0c127

Browse files
committed
BF: fixed a memory leak for MovieStim3
1 parent eadf758 commit 9d0c127

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Diff for: psychopy/visual/basevisual.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,8 @@ def clearTextures(self):
999999
of your stimulus, so doesn't need calling explicitly by the user.
10001000
"""
10011001
GL.glDeleteTextures(1, self._texID)
1002-
GL.glDeleteTextures(1, self._maskID)
1002+
if hasattr(self, '_maskID'):
1003+
GL.glDeleteTextures(1, self._maskID)
10031004

10041005
@attributeSetter
10051006
def mask(self, value):

Diff for: psychopy/visual/movie3.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from psychopy import logging, prefs #adding prefs to be able to check sound lib -JK
3939
from psychopy.tools.arraytools import val2array
4040
from psychopy.tools.attributetools import logAttrib, setAttribute
41-
from psychopy.visual.basevisual import BaseVisualStim, ContainerMixin
41+
from psychopy.visual.basevisual import BaseVisualStim, ContainerMixin, TextureMixin
4242

4343
from moviepy.video.io.VideoFileClip import VideoFileClip
4444

@@ -50,7 +50,7 @@
5050
import pyglet.gl as GL
5151

5252

53-
class MovieStim3(BaseVisualStim, ContainerMixin):
53+
class MovieStim3(BaseVisualStim, ContainerMixin, TextureMixin):
5454
"""A stimulus class for playing movies (mpeg, avi, etc...) in PsychoPy
5555
that does not require avbin. Instead it requires the cv2 python package
5656
for OpenCV. The VLC media player also needs to be installed on the
@@ -467,11 +467,8 @@ def _getAudioStreamTime(self):
467467
return self._audio_stream_clock.getTime()
468468

469469
def _unload(self):
470-
try:
471-
# remove textures from graphics card to prevent crash
472-
self.clearTextures()
473-
except Exception:
474-
pass
470+
# remove textures from graphics card to prevent crash
471+
self.clearTextures()
475472
if self._mov is not None:
476473
self._mov.close()
477474
self._mov = None

0 commit comments

Comments
 (0)