Commit e1c34221 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

oledb32: Implement IErrorRecord::AddErrorRecord.

parent 399bd421
......@@ -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;
}
......
......@@ -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);
}
......
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