cui/source/options/optgdlg.cxx |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit 1ec33490e92d884b75371e9227605f7d2f4f17e3
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Mar 17 07:28:39 2021 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Mar 17 14:14:08 2021 +0100

    Use COMReference here
    
    Change-Id: Ic9a12de597724e17c575336bb313f50ad1cecfa0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112612
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

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();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to