vcl/inc/quartz/salgdi.h            |   10 ++++------
 vcl/quartz/AquaGraphicsBackend.cxx |    2 +-
 vcl/skia/osx/gdiimpl.cxx           |    2 +-
 3 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit 0ae1a8cd12187b1b7197782d30d91c6a0d56f608
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Nov 30 17:31:20 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Nov 30 22:45:53 2022 +0100

    Avoid a dynamic cross cast on macOS
    
    ...now causing
    
    > In file included from vcl/osx/a11ytextattributeswrapper.mm:23:
    > vcl/inc/quartz/salgdi.h:283:22: error: suspicious dynamic cross cast from 
'AquaGraphicsBackendBase *' to 'SalGraphicsImpl *' [loplugin:crosscast]
    >             mpImpl = dynamic_cast<SalGraphicsImpl*>(this);
    >                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Change-Id: I0c9a4af0690c195c693f986e02284a48fe753a07
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143505
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 8a0fc4cfd3f0..61ff01c12e3a 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -272,15 +272,10 @@ struct AquaSharedAttributes
 class AquaGraphicsBackendBase
 {
 public:
-    AquaGraphicsBackendBase(AquaSharedAttributes& rShared)
-        : mrShared( rShared )
-    {}
     virtual ~AquaGraphicsBackendBase() = 0;
     AquaSharedAttributes& GetShared() { return mrShared; }
     SalGraphicsImpl* GetImpl()
     {
-        if(mpImpl == nullptr)
-            mpImpl = dynamic_cast<SalGraphicsImpl*>(this);
         return mpImpl;
     }
     virtual void UpdateGeometryProvider(SalGeometryProvider*) {};
@@ -293,6 +288,9 @@ public:
     virtual void Flush() {}
     virtual void Flush( const tools::Rectangle& ) {}
 protected:
+    AquaGraphicsBackendBase(AquaSharedAttributes& rShared, SalGraphicsImpl * 
impl)
+        : mrShared( rShared ), mpImpl(impl)
+    {}
     static bool performDrawNativeControl(ControlType nType,
                                          ControlPart nPart,
                                          const tools::Rectangle 
&rControlRegion,
@@ -302,7 +300,7 @@ protected:
                                          AquaSalFrame* mpFrame);
     AquaSharedAttributes& mrShared;
 private:
-    SalGraphicsImpl* mpImpl = nullptr;
+    SalGraphicsImpl* mpImpl;
 };
 
 inline AquaGraphicsBackendBase::~AquaGraphicsBackendBase() {}
diff --git a/vcl/quartz/AquaGraphicsBackend.cxx 
b/vcl/quartz/AquaGraphicsBackend.cxx
index aef2e3bb0f21..987ce5b784a5 100644
--- a/vcl/quartz/AquaGraphicsBackend.cxx
+++ b/vcl/quartz/AquaGraphicsBackend.cxx
@@ -190,7 +190,7 @@ void drawPattern50(void*, CGContextRef rContext)
 }
 
 AquaGraphicsBackend::AquaGraphicsBackend(AquaSharedAttributes& rShared)
-    : AquaGraphicsBackendBase(rShared)
+    : AquaGraphicsBackendBase(rShared, this)
 {
 }
 
diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index 6d65eedd0ec4..38927e92c9ca 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -38,7 +38,7 @@ using namespace SkiaHelper;
 AquaSkiaSalGraphicsImpl::AquaSkiaSalGraphicsImpl(AquaSalGraphics& rParent,
                                                  AquaSharedAttributes& rShared)
     : SkiaSalGraphicsImpl(rParent, rShared.mpFrame)
-    , AquaGraphicsBackendBase(rShared)
+    , AquaGraphicsBackendBase(rShared, this)
 {
     Init(); // mac code doesn't call Init()
 }

Reply via email to