From: Anton Baskanov baskanov@gmail.com
Some objects have no GUID or name (e.g. segments created from MIDI files), so ReleaseObject() won't find them in the cache. --- dlls/dmloader/loader.c | 7 +++++-- dlls/dmloader/tests/loader.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c index d8bad56c7f2..0291fffc06d 100644 --- a/dlls/dmloader/loader.c +++ b/dlls/dmloader/loader.c @@ -749,8 +749,11 @@ static HRESULT WINAPI loader_ClearCache(IDirectMusicLoader8 *iface, REFGUID clas LIST_FOR_EACH_ENTRY_SAFE(obj, obj2, &This->cache, struct cache_entry, entry) { if ((IsEqualGUID(class, &GUID_DirectMusicAllTypes) || IsEqualGUID(class, &obj->Desc.guidClass)) && (obj->Desc.dwValidData & DMUS_OBJ_LOADED)) { - /* basically, wrap to ReleaseObject for each object found */ - IDirectMusicLoader8_ReleaseObject(iface, obj->pObject); + if (obj->pObject) { + IDirectMusicObject_Release(obj->pObject); + obj->pObject = NULL; + } + obj->Desc.dwValidData &= ~DMUS_OBJ_LOADED; if (!IsEqualGUID(&GUID_DefaultGMCollection, &obj->Desc.guidObject)) { list_remove(&obj->entry); free(obj); diff --git a/dlls/dmloader/tests/loader.c b/dlls/dmloader/tests/loader.c index 3b6d9a159a8..4f7d52e566f 100644 --- a/dlls/dmloader/tests/loader.c +++ b/dlls/dmloader/tests/loader.c @@ -203,7 +203,7 @@ static void test_clear_cache(void) if (segment) { refcount = IDirectMusicSegment_Release(segment); - todo_wine ok(!refcount, "refcount == %lu, expected 0\n", refcount); + ok(!refcount, "refcount == %lu, expected 0\n", refcount); }
/* ClearCache doesn't remove the default collection */