Bug 1758997 - Remove RoInitialize/RoUninitialize from OSPreferences_win. r=Jamie

As per bug 1757647 comment 4, the main thread already initializes COM
early, and we should be able to rely on it in OSPreferences.

Differential Revision: https://phabricator.services.mozilla.com/D140745
This commit is contained in:
Emilio Cobos Álvarez 2022-03-11 10:02:32 +00:00
parent a1ba0b4ade
commit 1353b25e32
2 changed files with 31 additions and 45 deletions

View file

@ -35,13 +35,6 @@ bool OSPreferences::ReadSystemLocales(nsTArray<nsCString>& aLocaleList) {
// Try to get language list from GlobalizationPreferences; if this fails,
// we'll fall back to GetUserPreferredUILanguages.
// Per MSDN, these APIs are not available prior to Win8.
// RoInitialize may fail with "cannot change thread mode after it is set",
// if the runtime was already initialized on this thread.
// This appears to be harmless, and we can proceed to attempt the following
// runtime calls.
HRESULT inited = RoInitialize(RO_INIT_MULTITHREADED);
if (SUCCEEDED(inited) || inited == RPC_E_CHANGED_MODE) {
ComPtr<IGlobalizationPreferencesStatics> globalizationPrefs;
ComPtr<IVectorView<HSTRING>> languages;
uint32_t count;
@ -80,12 +73,6 @@ bool OSPreferences::ReadSystemLocales(nsTArray<nsCString>& aLocaleList) {
}
}
}
// Only close the runtime if we successfully initialized it above,
// otherwise we assume it was already in use and should be left as is.
if (SUCCEEDED(inited)) {
RoUninitialize();
}
}
#endif
// Per MSDN, GetUserPreferredUILanguages is available from Vista onwards,

View file

@ -30,7 +30,6 @@ forbid-mscom-init:
- browser/components/shell/nsWindowsShellService.cpp
- gfx/thebes/gfxWindowsPlatform.cpp
- image/DecodePool.cpp
- intl/locale/windows/OSPreferences_win.cpp
- ipc/glue/BrowserProcessSubThread.cpp
- netwerk/system/win32/nsNotifyAddrListener.cpp
- toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp