DirectShow: fix custom renderer reference counting.

Change-Id: Iadefd4d72bdafb982a79b99ee5880dba32f3e920
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
Yoann Lopes
2015-10-31 21:47:27 +01:00
parent 1c7543a640
commit 12fba3bfb1
2 changed files with 7 additions and 5 deletions

View File

@@ -45,7 +45,8 @@ DirectShowVideoRendererControl::DirectShowVideoRendererControl(DirectShowEventLo
DirectShowVideoRendererControl::~DirectShowVideoRendererControl() DirectShowVideoRendererControl::~DirectShowVideoRendererControl()
{ {
delete m_filter; if (m_filter)
m_filter->Release();
} }
QAbstractVideoSurface *DirectShowVideoRendererControl::surface() const QAbstractVideoSurface *DirectShowVideoRendererControl::surface() const
@@ -68,7 +69,8 @@ void DirectShowVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
emit filterChanged(); emit filterChanged();
delete existingFilter; if (existingFilter)
existingFilter->Release();
} }
} }

View File

@@ -69,7 +69,7 @@ VideoSurfaceFilter::VideoSurfaceFilter(
VideoSurfaceFilter::~VideoSurfaceFilter() VideoSurfaceFilter::~VideoSurfaceFilter()
{ {
Q_ASSERT(m_ref == 1); Q_ASSERT(m_ref == 0);
} }
HRESULT VideoSurfaceFilter::QueryInterface(REFIID riid, void **ppvObject) HRESULT VideoSurfaceFilter::QueryInterface(REFIID riid, void **ppvObject)
@@ -110,8 +110,8 @@ ULONG VideoSurfaceFilter::AddRef()
ULONG VideoSurfaceFilter::Release() ULONG VideoSurfaceFilter::Release()
{ {
ULONG ref = InterlockedDecrement(&m_ref); ULONG ref = InterlockedDecrement(&m_ref);
if (ref == 0)
Q_ASSERT(ref != 0); delete this;
return ref; return ref;
} }