diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-12-20 19:25:58 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-12-21 07:31:55 +0100 |
commit | 64e46c7cb0968a6249dd37ac0a7b12bccc19ee58 (patch) | |
tree | 5ac589ec706efb1a83eb0b188a7456b195d013e7 /avmedia/source | |
parent | 64065ade86cac68b9d500f0495ffc5745a944819 (diff) |
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 <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'avmedia/source')
-rw-r--r-- | avmedia/source/win/framegrabber.cxx | 2 | ||||
-rw-r--r-- | avmedia/source/win/player.cxx | 2 |
2 files changed, 2 insertions, 2 deletions
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<IMediaDet> implCreateMediaDet( const OUString& rURL { sal::systools::COMReference<IMediaDet> 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 |