Files
UnrealEngineUWP/Engine/Plugins/Developer/VisualStudioSourceCodeAccess
Kein 5087a03b39 PR #11750: Fixes VisualStudioSourceCodeAccessor raw CoCreateInstance call
#rb Paul.Chipchase, Martin.Ridgers
#jira UE-212297
#rnx

### Original change
- Add a call to ::CoInitialize in FVisualStudioSourceCodeAccessor::AddVisualStudioVersionUsingVisualStudioSetupAPI. The submitted had some use case where this could be called without CoInitialize already being in scope which was causing issues.

### Additional changes
- Added a new struct FCoInitializeScope that calls ::CoInitialize in it's constructor and ::CoUninitialize in it's destructor so that we can keep things in sync and reduce deplicate code such as logging an error if the call fails.
- - Replaced all existing manual calls to ::CoInitialize/::CoUninitialize with this struct.
- ::RefreshAvailability makes serveral calls to AddVisualStudioVersionUsingVisualStudioSetupAPI which in turn will call ::CoInitialize/::CoUninitialize, if we wrap the entire method in a FCoInitializeScope then we will only initialize and destroy once and the calls inside of AddVisualStudioVersionUsingVisualStudioSetupAPI just inc/dec the internal ref count.
-- In practice, since this is all called on the GameThread some other system will have called ::CoInitialize and maintained it's reference count so this makes no difference, but if a stand alone program wanted to use this module it might help.

[CL 35048631 by Kein in ue5-main branch]
2024-07-24 03:43:16 -04:00
..