From 64e46c7cb0968a6249dd37ac0a7b12bccc19ee58 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 20 Dec 2021 19:25:58 +0300 Subject: Introduce sal::systools::COMReference::TryCoCreateInstance Helps fixing uncaught exceptions introduced in commit 00eb9b8954a129fb365191ce8cdcbc4cf66a7333. TryCoCreateInstance returns HRESULT, because it allows to pass the info to the caller, which must check the result (either HRESULT, or validity of the reference) anyway. In case of failure, the previous contents of com_ptr_ is kept, which would be consistent with existing code in connectivity/ado replaced in a follow-up patch. Change-Id: I4c94695de96861ec312247acaa0c8fd35a23010a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127192 Tested-by: Mike Kaganski Reviewed-by: Mike Kaganski --- avmedia/source/win/framegrabber.cxx | 2 +- avmedia/source/win/player.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'avmedia/source') diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx index b7109b251497..17fb229ef057 100644 --- a/avmedia/source/win/framegrabber.cxx +++ b/avmedia/source/win/framegrabber.cxx @@ -65,7 +65,7 @@ sal::systools::COMReference implCreateMediaDet( const OUString& rURL { sal::systools::COMReference pDet; - if( pDet.CoCreateInstance(CLSID_MediaDet, nullptr, CLSCTX_INPROC_SERVER) ) + if( SUCCEEDED(pDet.TryCoCreateInstance(CLSID_MediaDet, nullptr, CLSCTX_INPROC_SERVER)) ) { OUString aLocalStr; diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx index ab2c9c8eb20d..23fdb241b3f5 100644 --- a/avmedia/source/win/player.cxx +++ b/avmedia/source/win/player.cxx @@ -96,7 +96,7 @@ bool Player::create( const OUString& rURL ) { bool bRet = false; - if( mpGB.CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC_SERVER) ) + if( SUCCEEDED(mpGB.TryCoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC_SERVER)) ) { // Don't use the overlay mixer on Windows Vista // It disables the desktop composition as soon as RenderFile is called -- cgit