From facb2f9a810b61e7d1e9c242fb1588effb0af5e3 Mon Sep 17 00:00:00 2001 From: Sander Mathijs van Veen Date: Wed, 23 Jul 2014 19:15:16 +0200 Subject: [PATCH] Reset class members to NULL after gst_*_unref() --- modules/videoio/src/cap_gstreamer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/videoio/src/cap_gstreamer.cpp b/modules/videoio/src/cap_gstreamer.cpp index c5a78a027..fea148f91 100644 --- a/modules/videoio/src/cap_gstreamer.cpp +++ b/modules/videoio/src/cap_gstreamer.cpp @@ -185,31 +185,41 @@ void CvCapture_GStreamer::close() if(pipeline) { gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL); gst_object_unref(GST_OBJECT(pipeline)); + pipeline = NULL; } if(uridecodebin){ gst_object_unref(GST_OBJECT(uridecodebin)); + uridecodebin = NULL; } if(color){ gst_object_unref(GST_OBJECT(color)); + color = NULL; } if(sink){ gst_object_unref(GST_OBJECT(sink)); + sink = NULL; } - if(buffer) + if(buffer) { gst_buffer_unref(buffer); + buffer = NULL; + } if(frame) { frame->imageData = 0; cvReleaseImage(&frame); + frame = NULL; } if(caps){ gst_caps_unref(caps); + caps = NULL; } if(buffer_caps){ gst_caps_unref(buffer_caps); + buffer_caps = NULL; } #if GST_VERSION_MAJOR > 0 if(sample){ gst_sample_unref(sample); + sample = NULL; } #endif