From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/uiautomationcore/uia_event.c | 5 ++++ dlls/uiautomationcore/uia_private.h | 3 ++ dlls/uiautomationcore/uia_utils.c | 46 +++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
diff --git a/dlls/uiautomationcore/uia_event.c b/dlls/uiautomationcore/uia_event.c index fb3b40f3d1e..beefabc83f6 100644 --- a/dlls/uiautomationcore/uia_event.c +++ b/dlls/uiautomationcore/uia_event.c @@ -154,6 +154,7 @@ static ULONG WINAPI uia_event_Release(IWineUiaEvent *iface) }
SafeArrayDestroy(event->runtime_id); + uia_cache_request_destroy(&event->cache_req); for (i = 0; i < event->event_advisers_count; i++) IWineUiaEventAdviser_Release(event->event_advisers[i]); heap_free(event->event_advisers); @@ -410,6 +411,10 @@ HRESULT WINAPI UiaAddEvent(HUIANODE huianode, EVENTID event_id, UiaEventCallback return hr; }
+ hr = uia_cache_request_clone(&event->cache_req, cache_req); + if (FAILED(hr)) + goto exit; + hr = attach_event_to_uia_node(huianode, event); if (FAILED(hr)) goto exit; diff --git a/dlls/uiautomationcore/uia_private.h b/dlls/uiautomationcore/uia_private.h index 0d652dd7b13..aea9882b240 100644 --- a/dlls/uiautomationcore/uia_private.h +++ b/dlls/uiautomationcore/uia_private.h @@ -109,6 +109,7 @@ struct uia_event struct list event_list_entry; struct uia_event_map_entry *event_map_entry;
+ struct UiaCacheRequest cache_req; UiaEventCallback *cback; };
@@ -185,6 +186,8 @@ HRESULT create_msaa_provider(IAccessible *acc, long child_id, HWND hwnd, BOOL kn HRESULT register_interface_in_git(IUnknown *iface, REFIID riid, DWORD *ret_cookie) DECLSPEC_HIDDEN; HRESULT unregister_interface_in_git(DWORD git_cookie) DECLSPEC_HIDDEN; HRESULT get_interface_in_git(REFIID riid, DWORD git_cookie, IUnknown **ret_iface) DECLSPEC_HIDDEN; +void uia_cache_request_destroy(struct UiaCacheRequest *cache_req) DECLSPEC_HIDDEN; +HRESULT uia_cache_request_clone(struct UiaCacheRequest *dst, struct UiaCacheRequest *src) DECLSPEC_HIDDEN; HRESULT get_safearray_dim_bounds(SAFEARRAY *sa, UINT dim, LONG *lbound, LONG *elems) DECLSPEC_HIDDEN; HRESULT get_safearray_bounds(SAFEARRAY *sa, LONG *lbound, LONG *elems) DECLSPEC_HIDDEN; int uia_compare_safearrays(SAFEARRAY *sa1, SAFEARRAY *sa2, int prop_type) DECLSPEC_HIDDEN; diff --git a/dlls/uiautomationcore/uia_utils.c b/dlls/uiautomationcore/uia_utils.c index ef7cf5ff9d2..97e903c2a45 100644 --- a/dlls/uiautomationcore/uia_utils.c +++ b/dlls/uiautomationcore/uia_utils.c @@ -98,6 +98,52 @@ HRESULT get_interface_in_git(REFIID riid, DWORD git_cookie, IUnknown **ret_iface return S_OK; }
+/* + * UiaCacheRequest cloning functions. + */ +void uia_cache_request_destroy(struct UiaCacheRequest *cache_req) +{ + heap_free(cache_req->pProperties); + heap_free(cache_req->pPatterns); +} + +HRESULT uia_cache_request_clone(struct UiaCacheRequest *dst, struct UiaCacheRequest *src) +{ + if (src->pViewCondition) + { + FIXME("Cache request condition cloning currently unimplemented\n"); + dst->pViewCondition = NULL; + } + + dst->Scope = src->Scope; + dst->automationElementMode = src->automationElementMode; + if (src->cProperties) + { + if (!(dst->pProperties = heap_alloc_zero(sizeof(*dst->pProperties) * src->cProperties))) + { + uia_cache_request_destroy(dst); + return E_OUTOFMEMORY; + } + + dst->cProperties = src->cProperties; + memcpy(dst->pProperties, src->pProperties, sizeof(*dst->pProperties) * dst->cProperties); + } + + if (src->cPatterns) + { + if (!(dst->pPatterns = heap_alloc_zero(sizeof(*dst->pPatterns) * src->cPatterns))) + { + uia_cache_request_destroy(dst); + return E_OUTOFMEMORY; + } + + dst->cPatterns = src->cPatterns; + memcpy(dst->pPatterns, src->pPatterns, sizeof(*dst->pPatterns) * dst->cPatterns); + } + + return S_OK; +} + HRESULT get_safearray_dim_bounds(SAFEARRAY *sa, UINT dim, LONG *lbound, LONG *elems) { LONG ubound;