summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-03-17 07:28:39 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2021-03-17 14:14:08 +0100
commit1ec33490e92d884b75371e9227605f7d2f4f17e3 (patch)
tree33b1671d29cfe49ddbae0cbc51a1e87f81965e9d
parentcb6ba06d286d0b44e0a54635588e33c2a650e0b8 (diff)
Use COMReference here
Change-Id: Ic9a12de597724e17c575336bb313f50ad1cecfa0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112612 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--cui/source/options/optgdlg.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index f15171e38103..673815bb60ab 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -89,6 +89,7 @@
#include <o3tl/char16_t2wchar_t.hxx>
#include <prewin.h>
#include <shobjidl.h>
+#include <systools/win32/comtools.hxx>
#include <postwin.h>
#endif
using namespace ::com::sun::star::uno;
@@ -367,20 +368,22 @@ IMPL_LINK_NOARG( OfaMiscTabPage, TwoFigureHdl, weld::SpinButton&, void )
IMPL_STATIC_LINK_NOARG(OfaMiscTabPage, FileAssocClick, weld::Button&, void)
{
const bool bUninit = SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED));
- IApplicationAssociationRegistrationUI* pIf = nullptr;
- HRESULT res = CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI, nullptr,
- CLSCTX_INPROC_SERVER, IID_IApplicationAssociationRegistrationUI,
- reinterpret_cast<LPVOID*>(&pIf));
-
- if (SUCCEEDED(res) && pIf)
+ try
{
+ auto pIf
+ = sal::systools::COMReference<IApplicationAssociationRegistrationUI>().CoCreateInstance(
+ CLSID_ApplicationAssociationRegistrationUI, nullptr, CLSCTX_INPROC_SERVER);
+
// LaunchAdvancedAssociationUI only works for applications registered under
// Software\RegisteredApplications. See scp2/source/ooo/registryitem_ooo.scp
const OUString expanded = Translate::ExpandVariables("%PRODUCTNAME %PRODUCTVERSION");
// This will only show "To change your default apps, go to Settings > Apps > Default apps"
// on Win10; this is expected. At least this will self-document it to users.
pIf->LaunchAdvancedAssociationUI(o3tl::toW(expanded.getStr()));
- pIf->Release();
+ }
+ catch (...)
+ {
+ // Just ignore any error here: this is not something we need to make sure to succeed
}
if (bUninit)
CoUninitialize();