[PATCH 3/3] oledb32: Implement GetCustomErrorObject()

Nikolay Sivov nsivov at codeweavers.com
Mon Nov 14 10:31:03 CST 2016


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/oledb32/errorinfo.c      | 25 ++++++++++++++-----------
 dlls/oledb32/tests/database.c |  6 ++++++
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/dlls/oledb32/errorinfo.c b/dlls/oledb32/errorinfo.c
index 7a1eddf..1820381 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,24 @@ 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;
+    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 e5c4a3f..ab5a282 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);
 
-- 
2.10.2




More information about the wine-patches mailing list