From: Anton Baskanov <baskanov(a)gmail.com> --- dlls/dmusic/port.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c index 84a9e759ab2..54e3f05965b 100644 --- a/dlls/dmusic/port.c +++ b/dlls/dmusic/port.c @@ -29,6 +29,7 @@ struct download_entry struct list entry; IDirectMusicDownload *download; HANDLE handle; + BOOL can_free; DWORD id; }; @@ -522,6 +523,7 @@ static HRESULT WINAPI synth_port_download_Download(IDirectMusicPortDownload *ifa IDirectMusicDownload_AddRef(download); entry->id = info->dwDLId; entry->handle = handle; + entry->can_free = can_free; list_add_tail(&This->downloads, &entry->entry); } @@ -529,6 +531,13 @@ static HRESULT WINAPI synth_port_download_Download(IDirectMusicPortDownload *ifa return hr; } +static HRESULT CALLBACK unload_callback(HANDLE handle, HANDLE user_data) +{ + IDirectMusicDownload *download = (IDirectMusicDownload *)user_data; + IDirectMusicDownload_Release(download); + return S_OK; +} + static HRESULT WINAPI synth_port_download_Unload(IDirectMusicPortDownload *iface, IDirectMusicDownload *download) { struct synth_port *This = synth_from_IDirectMusicPortDownload(iface); @@ -544,7 +553,8 @@ static HRESULT WINAPI synth_port_download_Unload(IDirectMusicPortDownload *iface if (entry->download == download) { list_remove(&entry->entry); - IDirectMusicDownload_Release(entry->download); + if (entry->can_free) + IDirectMusicDownload_Release(entry->download); handle = entry->handle; free(entry); break; @@ -552,7 +562,7 @@ static HRESULT WINAPI synth_port_download_Unload(IDirectMusicPortDownload *iface } if (!handle) return S_OK; - return IDirectMusicSynth_Unload(This->synth, handle, NULL, NULL); + return IDirectMusicSynth_Unload(This->synth, handle, unload_callback, download); } static const IDirectMusicPortDownloadVtbl synth_port_download_vtbl = { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9373