From: Michael Müller michael@fds-team.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38014 Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/dxdiagn/container.c | 12 ++++++++++-- dlls/dxdiagn/tests/container.c | 22 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/dlls/dxdiagn/container.c b/dlls/dxdiagn/container.c index 87d593a15a7..7a5a7e9d0a5 100644 --- a/dlls/dxdiagn/container.c +++ b/dlls/dxdiagn/container.c @@ -160,6 +160,14 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(IDxDiagContainer *i if (NULL == tmp) return E_FAIL; lstrcpynW(tmp, pwszContainer, tmp_len);
+ /* special handling for an empty string and leaf container */ + if (!tmp[0] && list_empty(&pContainer->subContainers)) { + hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, pContainer, This->pProv, (void **)ppInstance); + if (SUCCEEDED(hr)) + TRACE("Succeeded in getting the container instance\n"); + goto out; + } + cur = wcschr(tmp, '.'); while (NULL != cur) { *cur = '\0'; /* cut tmp string to '.' */ @@ -167,7 +175,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(IDxDiagContainer *i TRACE("Trying to get parent container %s\n", debugstr_w(tmp)); hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, &pContainer); if (FAILED(hr)) - goto on_error; + goto out; cur++; /* go after '.' (just replaced by \0) */ tmp = cur; cur = wcschr(tmp, '.'); @@ -181,7 +189,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(IDxDiagContainer *i TRACE("Succeeded in getting the container instance\n"); }
-on_error: +out: HeapFree(GetProcessHeap(), 0, orig_tmp); return hr; } diff --git a/dlls/dxdiagn/tests/container.c b/dlls/dxdiagn/tests/container.c index e335cf5b42e..a43324b3e8f 100644 --- a/dlls/dxdiagn/tests/container.c +++ b/dlls/dxdiagn/tests/container.c @@ -819,7 +819,7 @@ static void test_DxDiag_SystemInfo(void) {L"szProcessorEnglish", VT_BSTR}, };
- IDxDiagContainer *container; + IDxDiagContainer *container, *container2; HRESULT hr;
if (!create_root_IDxDiagContainer()) @@ -828,6 +828,9 @@ static void test_DxDiag_SystemInfo(void) return; }
+ hr = IDxDiagContainer_GetChildContainer(pddc, L"", &container2); + ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr); + hr = IDxDiagContainer_GetChildContainer(pddc, L"DxDiag_SystemInfo", &container); ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
@@ -835,6 +838,14 @@ static void test_DxDiag_SystemInfo(void) { trace("Testing container DxDiag_SystemInfo\n"); test_container_properties(container, property_tests, ARRAY_SIZE(property_tests)); + + container2 = NULL; + hr = IDxDiagContainer_GetChildContainer(container, L"", &container2); + ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); + ok(container2 != NULL, "Expected container2 != NULL\n"); + ok(container2 != container, "Expected container != container2\n"); + + IDxDiagContainer_Release(container2); IDxDiagContainer_Release(container); }
@@ -954,8 +965,8 @@ static void test_DxDiag_SoundDevices(void)
for (i = 0; i < count; i++) { + IDxDiagContainer *child, *child2; WCHAR child_container[256]; - IDxDiagContainer *child;
hr = IDxDiagContainer_EnumChildContainerNames(sound_cont, i, child_container, ARRAY_SIZE(child_container)); ok(hr == S_OK, "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr); @@ -966,6 +977,13 @@ static void test_DxDiag_SoundDevices(void) trace("Testing container %s\n", wine_dbgstr_w(child_container)); test_container_properties(child, property_tests, ARRAY_SIZE(property_tests));
+ child2 = NULL; + hr = IDxDiagContainer_GetChildContainer(child, L"", &child2); + ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); + ok(child2 != NULL, "Expected child2 != NULL\n"); + ok(child2 != child, "Expected child != child2\n"); + + IDxDiagContainer_Release(child2); IDxDiagContainer_Release(child); }