extensions/source/activex/SOActiveX.cxx |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

New commits:
commit c31c20a06540b4066e34de6cb320c0317840a952
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Jan 18 19:46:49 2025 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sun Jan 19 13:21:42 2025 +0100

    Use IID_PPV_ARGS and CComPtr to simplify
    
    IID_PPV_ARGS allows to avoid reinterpret_casts (and also explicit
    auto-deducible IIDs). Also, there always was a mismatch between the
    type of mWebBrowser2 (which is IWebBrowser2) and the queried IID in
    CSOActiveX::SetClientSite (which was IID_IWebBrowser, instead of
    the correct IID_IWebBrowser2). Looks like in practice it wasn't a
    problem, but now it's consistent.
    
    Use of CComPtr in CSOActiveX::Load allows to release the pointer
    correctly (previously, the call to Release was missing).
    
    Change-Id: I29d672052780a36465f6143106c22fa2c90dab5a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180448
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/extensions/source/activex/SOActiveX.cxx 
b/extensions/source/activex/SOActiveX.cxx
index b72ab0d66ca0..9bb3b34a4afe 100644
--- a/extensions/source/activex/SOActiveX.cxx
+++ b/extensions/source/activex/SOActiveX.cxx
@@ -146,7 +146,7 @@ CSOActiveX::CSOActiveX()
 , mbDrawLocked( false )
 {
     CLSID const clsFactory = {0x82154420,0x0FBF,0x11d4,{0x83, 
0x13,0x00,0x50,0x04,0x52,0x6A,0xB4}};
-    HRESULT hr = CoCreateInstance( clsFactory, nullptr, CLSCTX_ALL, 
__uuidof(IDispatch), reinterpret_cast<void**>(&mpDispFactory));
+    HRESULT hr = CoCreateInstance(clsFactory, nullptr, CLSCTX_ALL, 
IID_PPV_ARGS(&mpDispFactory));
     if( !SUCCEEDED( hr ) )
         OutputError_Impl( nullptr, hr );
 
@@ -303,8 +303,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CSOActiveX::Load( 
LPPROPERTYBAG pPropBag, LPER
 {
     mnVersion = GetVersionConnected();
 
-    IPropertyBag2* pPropBag2;
-    HRESULT hr = pPropBag->QueryInterface( IID_IPropertyBag2, 
reinterpret_cast<void**>(&pPropBag2) );
+    CComPtr<IPropertyBag2> pPropBag2;
+    HRESULT hr = pPropBag->QueryInterface(&pPropBag2);
     //ATLASSERT( hr >= 0 );
 
     if( !SUCCEEDED( hr ) )
@@ -1096,9 +1096,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP 
CSOActiveX::SetClientSite( IOleClientSite* aCl
 
         if( aServiceProvider )
         {
-            aServiceProvider->QueryService( SID_SInternetExplorer,
-                                            IID_IWebBrowser,
-                                            
reinterpret_cast<void**>(&mWebBrowser2) );
+            aServiceProvider->QueryService(SID_SInternetExplorer, 
IID_PPV_ARGS(&mWebBrowser2));
 //          ATLASSERT( mWebBrowser2 );
             if( mWebBrowser2 )
                 AtlAdvise( mWebBrowser2, GetUnknown(), 
DIID_DWebBrowserEvents2, &mCookie );

Reply via email to