Commit 1fe904bd authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

dxdiagn: Avoid caching a single instance of the root container.

parent c99e0fbc
...@@ -48,7 +48,6 @@ struct IDxDiagProviderImpl { ...@@ -48,7 +48,6 @@ struct IDxDiagProviderImpl {
/* IDxDiagProvider fields */ /* IDxDiagProvider fields */
BOOL init; BOOL init;
DXDIAG_INIT_PARAMS params; DXDIAG_INIT_PARAMS params;
IDxDiagContainer* pRootContainer;
}; };
/* ---------------- */ /* ---------------- */
......
...@@ -107,21 +107,24 @@ static HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDI ...@@ -107,21 +107,24 @@ static HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDI
} }
static HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) { static HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) {
HRESULT hr = S_OK; HRESULT hr;
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface; IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
IDxDiagContainer *root;
TRACE("(%p,%p)\n", iface, ppInstance); TRACE("(%p,%p)\n", iface, ppInstance);
if (FALSE == This->init) { if (FALSE == This->init) {
return CO_E_NOTINITIALIZED; return CO_E_NOTINITIALIZED;
} }
if (NULL == This->pRootContainer) {
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &This->pRootContainer); hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void **)&root);
if (FAILED(hr)) { if (FAILED(hr)) {
return hr; return hr;
}
hr = DXDiag_InitRootDXDiagContainer(This->pRootContainer);
} }
return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)This->pRootContainer, &IID_IDxDiagContainer, (void**) ppInstance);
DXDiag_InitRootDXDiagContainer(root);
return IDxDiagContainerImpl_QueryInterface(root, &IID_IDxDiagContainer, (void **)ppInstance);
} }
static const IDxDiagProviderVtbl DxDiagProvider_Vtbl = static const IDxDiagProviderVtbl DxDiagProvider_Vtbl =
......
...@@ -94,7 +94,7 @@ static void test_GetRootContainer(void) ...@@ -94,7 +94,7 @@ static void test_GetRootContainer(void)
{ {
HRESULT hr; HRESULT hr;
IDxDiagProvider *pddp; IDxDiagProvider *pddp;
IDxDiagContainer *pddc; IDxDiagContainer *pddc, *pddc2;
DXDIAG_INIT_PARAMS params; DXDIAG_INIT_PARAMS params;
hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
...@@ -140,6 +140,13 @@ static void test_GetRootContainer(void) ...@@ -140,6 +140,13 @@ static void test_GetRootContainer(void)
hr = IDxDiagProvider_GetRootContainer(pddp, &pddc); hr = IDxDiagProvider_GetRootContainer(pddp, &pddc);
ok(hr == S_OK, "Expected IDxDiagProvider::GetRootContainer to return S_OK, got %x\n", hr); ok(hr == S_OK, "Expected IDxDiagProvider::GetRootContainer to return S_OK, got %x\n", hr);
/* IDxDiagProvider::GetRootContainer creates new instances of the root
* container rather than maintain a static root container. */
hr = IDxDiagProvider_GetRootContainer(pddp, &pddc2);
ok(hr == S_OK, "Expected IDxDiagProvider::GetRootContainer to return S_OK, got %x\n", hr);
ok(pddc != pddc2, "Expected the two pointers (%p vs. %p) to be unequal\n", pddc, pddc2);
IDxDiagContainer_Release(pddc2);
IDxDiagContainer_Release(pddc); IDxDiagContainer_Release(pddc);
IDxDiagProvider_Release(pddp); IDxDiagProvider_Release(pddp);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment