vcl/skia/gdiimpl.cxx |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

New commits:
commit ebee2930a3558c5eb8921e1b5f3e275702f8a64f
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Mar 3 14:00:06 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Mar 3 12:07:29 2023 +0000

    Fix SAL_INFO dereferencing optionals
    
    Change-Id: I6d8ec4cd481284a42db33bf85ec7770fbb89cf83
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148168
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 0ffafb040a46..f26b2d26711b 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -41,6 +41,8 @@
 #include <SkRSXform.h>
 
 #include <numeric>
+#include <sstream>
+
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
@@ -216,6 +218,17 @@ bool checkInvalidSourceOrDestination(SalTwoRect const& 
rPosAry)
            || rPosAry.mnDestHeight <= 0;
 }
 
+std::string dumpOptionalColor(const std::optional<Color>& c)
+{
+    std::ostringstream oss;
+    if (c)
+        oss << *c;
+    else
+        oss << "no color";
+
+    return std::move(oss).str(); // optimized in C++20
+}
+
 } // end anonymous namespace
 
 // Class that triggers flushing the backing buffer when idle.
@@ -738,8 +751,8 @@ void SkiaSalGraphicsImpl::privateDrawAlphaRect(tools::Long 
nX, tools::Long nY, t
     preDraw();
     SAL_INFO("vcl.skia.trace", "privatedrawrect("
                                    << this << "): " << SkIRect::MakeXYWH(nX, 
nY, nWidth, nHeight)
-                                   << ":" << *moLineColor << ":" << 
*moFillColor << ":"
-                                   << fTransparency);
+                                   << ":" << dumpOptionalColor(moLineColor) << 
":"
+                                   << dumpOptionalColor(moFillColor) << ":" << 
fTransparency);
     addUpdateRegion(SkRect::MakeXYWH(nX, nY, nWidth, nHeight));
     SkCanvas* canvas = getDrawCanvas();
     if (moFillColor)
@@ -840,7 +853,8 @@ bool SkiaSalGraphicsImpl::drawPolyPolygon(const 
basegfx::B2DHomMatrix& rObjectTo
     aPolyPolygon.transform(rObjectToDevice);
 
     SAL_INFO("vcl.skia.trace", "drawpolypolygon(" << this << "): " << 
aPolyPolygon << ":"
-                                                  << *moLineColor << ":" << 
*moFillColor);
+                                                  << 
dumpOptionalColor(moLineColor) << ":"
+                                                  << 
dumpOptionalColor(moFillColor));
 
     if (delayDrawPolyPolygon(aPolyPolygon, fTransparency))
     {

Reply via email to