Alistair Leslie-Hughes : oledb32: Implement IErrorRecord::AddErrorRecord.

Alexandre Julliard julliard at winehq.org
Tue Aug 20 14:38:37 CDT 2013


Module: wine
Branch: master
Commit: e1c34221b33dbde0d3e8c97eff70783377ecead4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e1c34221b33dbde0d3e8c97eff70783377ecead4

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Mon Aug 19 11:13:34 2013 +1000

oledb32: Implement IErrorRecord::AddErrorRecord.

---

 dlls/oledb32/errorinfo.c      |   31 ++++++++++++++++++++++++++++---
 dlls/oledb32/tests/database.c |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/dlls/oledb32/errorinfo.c b/dlls/oledb32/errorinfo.c
index eef2b37..4a2a1e2 100644
--- a/dlls/oledb32/errorinfo.c
+++ b/dlls/oledb32/errorinfo.c
@@ -41,7 +41,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(oledb);
 struct ErrorEntry
 {
     struct list entry;
-    ERRORINFO*      info;
+    ERRORINFO       info;
     DISPPARAMS      dispparams;
     IUnknown        *unknown;
     DWORD           lookupID;
@@ -109,6 +109,7 @@ static ULONG WINAPI IErrorInfoImpl_Release(IErrorInfo* iface)
 {
     ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
     ULONG ref = InterlockedDecrement(&This->ref);
+    struct ErrorEntry *cursor, *cursor2;
 
     TRACE("(%p)->%u\n",This,ref+1);
 
@@ -117,6 +118,15 @@ static ULONG WINAPI IErrorInfoImpl_Release(IErrorInfo* iface)
         SysFreeString(This->source);
         SysFreeString(This->description);
         SysFreeString(This->help_file);
+
+        LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->errors, struct ErrorEntry, entry)
+        {
+            list_remove(&cursor->entry);
+            if(cursor->unknown)
+                IUnknown_Release(cursor->unknown);
+
+            heap_free(cursor);
+        }
         heap_free(This);
     }
     return ref;
@@ -226,12 +236,27 @@ static HRESULT WINAPI errorrec_AddErrorRecord(IErrorRecords *iface, ERRORINFO *p
         DWORD dwLookupID, DISPPARAMS *pdispparams, IUnknown *punkCustomError, DWORD dwDynamicErrorID)
 {
     ErrorInfoImpl *This = impl_from_IErrorRecords(iface);
+    struct ErrorEntry *entry;
 
-    FIXME("(%p)->(%p %d %p %p %d)\n", This, pErrorInfo, dwLookupID, pdispparams, punkCustomError, dwDynamicErrorID);
+    TRACE("(%p)->(%p %d %p %p %d)\n", This, pErrorInfo, dwLookupID, pdispparams, punkCustomError, dwDynamicErrorID);
 
-    if(pErrorInfo)
+    if(!pErrorInfo)
         return E_INVALIDARG;
 
+    entry = heap_alloc(sizeof(*entry));
+    if(!entry)
+        return E_OUTOFMEMORY;
+
+    entry->info = *pErrorInfo;
+    if(pdispparams)
+        entry->dispparams = *pdispparams;
+    entry->unknown = punkCustomError;
+    if(entry->unknown)
+        IUnknown_AddRef(entry->unknown);
+    entry->lookupID = dwDynamicErrorID;
+
+    list_add_head(&This->errors, &entry->entry);
+
     return S_OK;
 }
 
diff --git a/dlls/oledb32/tests/database.c b/dlls/oledb32/tests/database.c
index 7b129b8..f41fd6c 100644
--- a/dlls/oledb32/tests/database.c
+++ b/dlls/oledb32/tests/database.c
@@ -31,6 +31,7 @@
 #include "shlobj.h"
 #include "msdaguid.h"
 #include "initguid.h"
+#include "oledberr.h"
 
 #include "wine/test.h"
 
@@ -159,6 +160,45 @@ static void test_errorinfo(void)
         ok(hr == S_OK, "got %08x\n", hr);
         if(hr == S_OK)
         {
+            ERRORINFO info, info2, info3;
+            ULONG cnt = 0;
+
+            memset(&info, 0, sizeof(ERRORINFO));
+            info.dwMinor = 1;
+            memset(&info2, 0, sizeof(ERRORINFO));
+            info2.dwMinor = 2;
+            memset(&info3, 0, sizeof(ERRORINFO));
+
+            hr = IErrorRecords_AddErrorRecord(errrecs, NULL, 268435456, NULL, NULL, 0);
+            ok(hr == E_INVALIDARG, "got %08x\n", hr);
+
+            hr = IErrorRecords_AddErrorRecord(errrecs, &info, 1, NULL, NULL, 0);
+            ok(hr == S_OK, "got %08x\n", hr);
+
+            hr = IErrorRecords_GetRecordCount(errrecs, &cnt);
+            ok(hr == S_OK, "got %08x\n", hr);
+            ok(cnt == 1, "expected 1 got %d\n", cnt);
+
+            hr = IErrorRecords_AddErrorRecord(errrecs, &info2, 2, NULL, NULL, 0);
+            ok(hr == S_OK, "got %08x\n", hr);
+
+            hr = IErrorRecords_GetRecordCount(errrecs, &cnt);
+            ok(hr == S_OK, "got %08x\n", hr);
+            ok(cnt == 2, "expected 2 got %d\n", cnt);
+
+            hr = IErrorRecords_GetBasicErrorInfo(errrecs, 0, NULL);
+            ok(hr == E_INVALIDARG, "got %08x\n", hr);
+
+            hr = IErrorRecords_GetBasicErrorInfo(errrecs, 100, &info3);
+            ok(hr == DB_E_BADRECORDNUM, "got %08x\n", hr);
+
+            hr = IErrorRecords_GetBasicErrorInfo(errrecs, 0, &info3);
+            todo_wine ok(hr == S_OK, "got %08x\n", hr);
+            if(hr == S_OK)
+            {
+                ok(info3.dwMinor == 2, "expected 2 got %d\n", info3.dwMinor);
+            }
+
             IErrorRecords_Release(errrecs);
         }
 




More information about the wine-cvs mailing list