From 333039f318168a7c40c20d6357a4f69899146399 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 15 Nov 2016 20:26:49 +0300 Subject: [PATCH] oledb32: Implement GetCustomErrorObject(). Signed-off-by: Nikolay Sivov Signed-off-by: Alistair Leslie-Hughes Signed-off-by: Alexandre Julliard --- dlls/oledb32/errorinfo.c | 26 +++++++++++++++----------- dlls/oledb32/tests/database.c | 6 ++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/dlls/oledb32/errorinfo.c b/dlls/oledb32/errorinfo.c index 7a1eddf5c5c..48db723eca6 100644 --- a/dlls/oledb32/errorinfo.c +++ b/dlls/oledb32/errorinfo.c @@ -42,7 +42,7 @@ struct ErrorEntry { ERRORINFO info; DISPPARAMS dispparams; - IUnknown *unknown; + IUnknown *custom_error; DWORD lookupID; }; @@ -113,8 +113,8 @@ static ULONG WINAPI IErrorInfoImpl_Release(IErrorInfo* iface) for (i = 0; i < This->count; i++) { - if (This->records[i].unknown) - IUnknown_Release(This->records[i].unknown); + if (This->records[i].custom_error) + IUnknown_Release(This->records[i].custom_error); } heap_free(This->records); heap_free(This); @@ -257,9 +257,9 @@ static HRESULT WINAPI errorrec_AddErrorRecord(IErrorRecords *iface, ERRORINFO *p entry->info = *pErrorInfo; if(pdispparams) entry->dispparams = *pdispparams; - entry->unknown = punkCustomError; - if(entry->unknown) - IUnknown_AddRef(entry->unknown); + entry->custom_error = punkCustomError; + if (entry->custom_error) + IUnknown_AddRef(entry->custom_error); entry->lookupID = dwDynamicErrorID; This->count++; @@ -283,21 +283,25 @@ static HRESULT WINAPI errorrec_GetBasicErrorInfo(IErrorRecords *iface, ULONG ind } static HRESULT WINAPI errorrec_GetCustomErrorObject(IErrorRecords *iface, ULONG index, - REFIID riid, IUnknown **ppObject) + REFIID riid, IUnknown **object) { ErrorInfoImpl *This = impl_from_IErrorRecords(iface); - FIXME("(%p)->(%u %s, %p)\n", This, index, debugstr_guid(riid), ppObject); + TRACE("(%p)->(%u %s %p)\n", This, index, debugstr_guid(riid), object); - if (!ppObject) + if (!object) return E_INVALIDARG; - *ppObject = NULL; + *object = NULL; if (index >= This->count) return DB_E_BADRECORDNUM; - return E_NOTIMPL; + index = This->count - index - 1; + if (This->records[index].custom_error) + return IUnknown_QueryInterface(This->records[index].custom_error, riid, (void **)object); + else + return S_OK; } static HRESULT WINAPI errorrec_GetErrorInfo(IErrorRecords *iface, ULONG index, diff --git a/dlls/oledb32/tests/database.c b/dlls/oledb32/tests/database.c index 68f9eacce80..980dacd4181 100644 --- a/dlls/oledb32/tests/database.c +++ b/dlls/oledb32/tests/database.c @@ -414,6 +414,12 @@ static void test_errorinfo(void) ok(hr == S_OK, "got %08x\n", hr); ok(cnt == 1, "expected 1 got %d\n", cnt); + /* Record does not contain custom error object. */ + unk2 = (void*)0xdeadbeef; + hr = IErrorRecords_GetCustomErrorObject(errrecs, 0, &IID_IUnknown, &unk2); + ok(hr == S_OK, "got %08x\n", hr); + ok(unk2 == NULL, "Got custom object %p.\n", unk2); + hr = IErrorRecords_AddErrorRecord(errrecs, &info2, 2, NULL, NULL, 0); ok(hr == S_OK, "got %08x\n", hr);