summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-09-13 11:29:37 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-09-15 06:08:27 +0200
commit96bd77de5ad7b7a13f7e48e0f95c05ef49255aa0 (patch)
tree4c79c57712124a8589c9e6579b6ec7fec9200c3b /framework
parent3f65724ec5fc92d5a0078a99932358ef7091435c (diff)
Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 5
- Revise uses of getSomething to use getFromUnoTunnel Where that is impossible, use getSomething_cast to unify casting, and minimize number of places doing low-level transformations. The change keeps the existing tunnel references that last for the duration of the pointers' life, because sometimes destroying such reference may destroy the pointed object, and result in use after free. Change-Id: I291c33223582c34cd2c763aa8aacf0ae899ca4c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122101 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/fwe/helper/actiontriggerhelper.cxx20
1 files changed, 8 insertions, 12 deletions
diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx
index 9cff941e23c3..d96e44cb9bae 100644
--- a/framework/source/fwe/helper/actiontriggerhelper.cxx
+++ b/framework/source/fwe/helper/actiontriggerhelper.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/awt/XBitmap.hpp>
#include <vcl/svapp.hxx>
#include <tools/stream.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/weak.hxx>
#include <vcl/dibtools.hxx>
@@ -152,21 +153,16 @@ static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Refer
bool bImageSet = false;
Reference< XUnoTunnel > xUnoTunnel( xBitmap, UNO_QUERY );
- if ( xUnoTunnel.is() )
+ // Try to get implementation pointer through XUnoTunnel
+ if (auto pImageWrapper = comphelper::getFromUnoTunnel<ImageWrapper>(xUnoTunnel))
{
- // Try to get implementation pointer through XUnoTunnel
- sal_Int64 nPointer = xUnoTunnel->getSomething( ImageWrapper::getUnoTunnelId() );
- if ( nPointer )
- {
- // This is our own optimized implementation of menu images!
- ImageWrapper* pImageWrapper = reinterpret_cast< ImageWrapper * >( nPointer );
- const Image& aMenuImage = pImageWrapper->GetImage();
+ // This is our own optimized implementation of menu images!
+ const Image& aMenuImage = pImageWrapper->GetImage();
- if ( !!aMenuImage )
- pSubMenu->SetItemImage( nNewItemId, aMenuImage );
+ if ( !!aMenuImage )
+ pSubMenu->SetItemImage( nNewItemId, aMenuImage );
- bImageSet = true;
- }
+ bImageSet = true;
}
if ( !bImageSet )