Skip to content

Commit

Permalink
Actually terminate (clean up) the Microsoft UIA Abstraction remote op…
Browse files Browse the repository at this point in the history
…erations librry on NVDA exit.
  • Loading branch information
michaelDCurran committed Feb 24, 2024
1 parent b31f305 commit 0258db7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
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.
extern "C" __declspec(dllexport) void __stdcall cleanup() {
if(_isInitialized) {
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
3 changes: 3 additions & 0 deletions source/UIAHandler/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def initialize(doRemote: bool, UIAClient: POINTER(UIA.IUIAutomation)):
_dll = windll[os.path.join(NVDAHelper.versionedLibPath, "UIARemote.dll")]
_dll.initialize(doRemote, UIAClient)

def terminate():
_dll.cleanup()


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

0 comments on commit 0258db7

Please sign in to comment.