Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually terminate (clean up) the Microsoft UIA Abstraction remote operations library on NVDA exit. #16222

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions nvdaHelper/UIARemote/UIARemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ extern "C" __declspec(dllexport) bool __stdcall initialize(bool doRemote, IUIAut
return true;
}

// Cleans up the remote opperations library.
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
extern "C" __declspec(dllexport) void __stdcall cleanup() {
if(_isInitialized) {
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
LOG_INFO(L"Cleaning up the UIA Remote Operations abstraction library...")
UiaOperationAbstraction::Cleanup();
_isInitialized = false;
LOG_INFO(L"Done")
}
}


BOOL WINAPI DllMain(HINSTANCE hModule,DWORD reason,LPVOID lpReserved) {
if(reason==DLL_PROCESS_ATTACH) {
GetModuleFileName(hModule,dllDirectory,MAX_PATH);
Expand Down
2 changes: 2 additions & 0 deletions source/UIAHandler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ def MTAThreadFunc(self):
else:
break
self.clientObject.RemoveAllEventHandlers()
if winVersion.getWinVer() >= winVersion.WIN11:
UIARemote.terminate()

def _registerGlobalEventHandlers(self):
self.clientObject.AddFocusChangedEventHandler(self.baseCacheRequest, self)
Expand Down
5 changes: 5 additions & 0 deletions source/UIAHandler/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def initialize(doRemote: bool, UIAClient: POINTER(UIA.IUIAutomation)):
_dll.initialize(doRemote, UIAClient)


def terminate():
""" Terminates UIA remote operations support."""
_dll.cleanup()


def msWord_getCustomAttributeValue(
docElement: POINTER(UIA.IUIAutomationElement),
textRange: POINTER(UIA.IUIAutomationTextRange),
Expand Down