[Libreoffice-commits] core.git: toolkit/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu May 13 18:52:53 UTC 2021


 toolkit/source/helper/unowrapper.cxx |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

New commits:
commit 883b7a34d288410ac6f820e91d9eaa65ba2b9cb1
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu May 13 18:12:22 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu May 13 20:52:05 2021 +0200

    DBG_ASSERT->assert in UnoWrapper
    
    Change-Id: Ibc6b489f12c2734869bd45f93f946a53e3015226
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115564
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx
index d4f0b3501ca9..8474b45399c4 100644
--- a/toolkit/source/helper/unowrapper.cxx
+++ b/toolkit/source/helper/unowrapper.cxx
@@ -35,7 +35,7 @@
 
 using namespace ::com::sun::star;
 
-static css::uno::Reference< css::awt::XWindowPeer > CreateXWindow( vcl::Window const * pWindow )
+static rtl::Reference<VCLXWindow> CreateXWindow( vcl::Window const * pWindow )
 {
     switch ( pWindow->GetType() )
     {
@@ -148,12 +148,13 @@ css::uno::Reference< css::awt::XToolkit> UnoWrapper::GetVCLToolkit()
 css::uno::Reference< css::awt::XWindowPeer> UnoWrapper::GetWindowInterface( vcl::Window* pWindow )
 {
     css::uno::Reference< css::awt::XWindowPeer> xPeer = pWindow->GetWindowPeer();
-    if ( !xPeer.is() )
-    {
-        xPeer = CreateXWindow( pWindow );
-        SetWindowInterface( pWindow, xPeer );
-    }
-    return xPeer;
+    if ( xPeer )
+        return xPeer;
+
+    rtl::Reference<VCLXWindow> xVCLXWindow = CreateXWindow( pWindow );
+    xVCLXWindow->SetWindow( pWindow );
+    pWindow->SetWindowPeer( xVCLXWindow, xVCLXWindow.get() );
+    return xVCLXWindow;
 }
 
 VclPtr<vcl::Window> UnoWrapper::GetWindow(const css::uno::Reference<css::awt::XWindow>& rWindow)
@@ -165,7 +166,7 @@ void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, const css::uno::Refer
 {
     VCLXWindow* pVCLXWindow = comphelper::getUnoTunnelImplementation<VCLXWindow>( xIFace );
 
-    DBG_ASSERT( pVCLXWindow, "SetComponentInterface - unsupported type" );
+    assert( pVCLXWindow && "must be a VCLXWindow subclass" );
     if ( !pVCLXWindow )
         return;
 
@@ -173,7 +174,7 @@ void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, const css::uno::Refer
     if( xPeer.is() )
     {
         bool bSameInstance( pVCLXWindow == dynamic_cast< VCLXWindow* >( xPeer.get() ));
-        DBG_ASSERT( bSameInstance, "UnoWrapper::SetWindowInterface: there already *is* a WindowInterface for this window!" );
+        assert( bSameInstance && "UnoWrapper::SetWindowInterface: there is already a WindowPeer/ComponentInterface for this VCL window" );
         if ( bSameInstance )
             return;
     }


More information about the Libreoffice-commits mailing list