From: Piotr Caban <piotr@codeweavers.com> --- dlls/msado15/connection.c | 62 +++++++++++++++++++++--------------- dlls/msado15/tests/msado15.c | 8 +++++ 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/dlls/msado15/connection.c b/dlls/msado15/connection.c index df8571f978e..76438daa31f 100644 --- a/dlls/msado15/connection.c +++ b/dlls/msado15/connection.c @@ -969,32 +969,44 @@ static HRESULT WINAPI adoconstruct_WrapDSOandSession(ADOConnectionConstruction15 TRACE("%p, %p, %p\n", connection, dso, session); - hr = IUnknown_QueryInterface( dso, &IID_IDBProperties, (void **)&props ); - if (FAILED(hr)) return hr; - propset.guidPropertySet = DBPROPSET_DBINIT; - propset.cProperties = ARRAY_SIZE(prop); - propset.rgProperties = prop; - memset(prop, 0, sizeof(prop)); - prop[0].dwPropertyID = DBPROP_INIT_TIMEOUT; - prop[0].dwOptions = DBPROPOPTIONS_OPTIONAL; - V_VT(&prop[0].vValue) = VT_I4; - V_I4(&prop[0].vValue) = connection->conn_timeout; - prop[1].dwPropertyID = DBPROP_INIT_OLEDBSERVICES; - prop[1].dwOptions = DBPROPOPTIONS_REQUIRED; - V_VT(&prop[1].vValue) = VT_I4; - V_I4(&prop[1].vValue) = DBPROPVAL_OS_ENABLEALL; - if (connection->location != adUseClient) - V_I4(&prop[1].vValue) &= ~DBPROPVAL_OS_CLIENTCURSOR; - hr = IDBProperties_SetProperties( props, 1, &propset ); - IDBProperties_Release( props ); - if (FAILED(hr)) FIXME("SetProperties failed: %lx\n", hr); - - hr = IUnknown_QueryInterface( dso, &IID_IDBInitialize, (void **)&dbinit ); - if (FAILED(hr)) return hr; + if (dso) + { + if (connection->dso) return E_ACCESSDENIED; + + hr = IUnknown_QueryInterface( dso, &IID_IDBProperties, (void **)&props ); + if (FAILED(hr)) return hr; + propset.guidPropertySet = DBPROPSET_DBINIT; + propset.cProperties = ARRAY_SIZE(prop); + propset.rgProperties = prop; + memset(prop, 0, sizeof(prop)); + prop[0].dwPropertyID = DBPROP_INIT_TIMEOUT; + prop[0].dwOptions = DBPROPOPTIONS_OPTIONAL; + V_VT(&prop[0].vValue) = VT_I4; + V_I4(&prop[0].vValue) = connection->conn_timeout; + prop[1].dwPropertyID = DBPROP_INIT_OLEDBSERVICES; + prop[1].dwOptions = DBPROPOPTIONS_REQUIRED; + V_VT(&prop[1].vValue) = VT_I4; + V_I4(&prop[1].vValue) = DBPROPVAL_OS_ENABLEALL; + if (connection->location != adUseClient) + V_I4(&prop[1].vValue) &= ~DBPROPVAL_OS_CLIENTCURSOR; + hr = IDBProperties_SetProperties( props, 1, &propset ); + IDBProperties_Release( props ); + if (FAILED(hr)) FIXME("SetProperties failed: %lx\n", hr); + + hr = IUnknown_QueryInterface( dso, &IID_IDBInitialize, (void **)&dbinit ); + if (FAILED(hr)) return hr; + + connection->dso = dbinit; + } + + if (session) + { + if (connection->session) + IUnknown_Release(connection->session); + connection->session = session; + IUnknown_AddRef( session ); + } - connection->dso = dbinit; - connection->session = session; - IUnknown_AddRef( session ); connection->state = adStateOpen; return S_OK; } diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index 03424b9e929..3b5faec7eb7 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -3574,6 +3574,13 @@ static void test_ADOConnectionConstruction(void) hr = _Connection_QueryInterface(conn, &IID_ADOConnectionConstruction15, (void **)&conn_constr); ok(hr == S_OK, "got %08lx\n", hr); + + hr = ADOConnectionConstruction15_WrapDSOandSession(conn_constr, NULL, NULL); + ok(hr == S_OK, "got %08lx\n", hr); + hr = _Connection_get_State(conn, &state); + ok(hr == S_OK, "got %08lx\n", hr); + ok(state == adStateOpen, "state = %ld\n", state); + SET_EXPECT(open_rowset_QI_ISessionProperties); SET_EXPECT(open_rowset_QI_IBindResource); SET_EXPECT(open_rowset_QI_ICreateRow); @@ -3587,6 +3594,7 @@ static void test_ADOConnectionConstruction(void) todo_wine CHECK_CALLED(open_rowset_QI_ICreateRow); todo_wine CHECK_CALLED(dbprops_GetProperties); CHECK_CALLED(dbprops_SetProperties); + ADOConnectionConstruction15_Release(conn_constr); hr = _Connection_get_State(conn, &state); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9895