GSCapture: Fix a premature GSSource release

CUnknown starts with a refcount of 0, so a "nonstandard"
assignment needs to be performed, even though it looks like
a COM reference leak at the first glance.
This commit is contained in:
Silent 2021-09-21 21:24:49 +02:00 committed by Kojin
parent 4c941f81ec
commit 0ab31a2e9f
1 changed files with 4 additions and 2 deletions

View File

@ -470,8 +470,10 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float
}
HRESULT source_hr = S_OK;
wil::com_ptr_nothrow<IBaseFilter> src;
src.attach(new GSSource(m_size.x, m_size.y, fps, NULL, source_hr, dlg.m_colorspace));
// WARNING: This increases the reference count! Right now it's fine, since GSSource inherits from CUnknown that
// starts the reference count from 0. Should this ever change and GSSource ends up with a refcount of 1 after constructing,
// change this to `.attach(new GSSource(...))`.
wil::com_ptr_nothrow<IBaseFilter> src = new GSSource(m_size.x, m_size.y, fps, NULL, source_hr, dlg.m_colorspace);
if (dlg.m_enc == 0)
{