From e4a8a4f15cd567dbb3c6414df36d2a3d39dc073c Mon Sep 17 00:00:00 2001 From: Lucien Fiorini Date: Mon, 16 Dec 2024 10:48:20 +0100 Subject: [PATCH] LibGfx: Fix dynamic_cast undefined behavior on macOS MacOS XCode 16 breaks dynamic_cast on final classes where the base class has a has a virtual destructor defined in the header, which creates a different virtual table per translation unit. This is probably a regression in Apple's Clang that causes final classes to be incorrectly aggressively optimized. https://stackoverflow.com/questions/79192304/macos-xcode-16-breaks-dynamic-cast-for-final-types-defined-in-shared-library --- Libraries/LibGfx/PaintStyle.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/LibGfx/PaintStyle.h b/Libraries/LibGfx/PaintStyle.h index 1acbba397b6f..9ebf66736e08 100644 --- a/Libraries/LibGfx/PaintStyle.h +++ b/Libraries/LibGfx/PaintStyle.h @@ -38,7 +38,7 @@ class PaintStyle : public RefCounted { virtual Color sample_color(IntPoint) const { return Color(); } }; -class SolidColorPaintStyle final : public PaintStyle { +class SolidColorPaintStyle : public PaintStyle { public: static ErrorOr> create(Color color) { @@ -90,7 +90,7 @@ class GradientPaintStyle : public PaintStyle { // These gradients are (unlike CSS ones) not relative to the painted shape, and do not // support premultiplied alpha. -class CanvasLinearGradientPaintStyle final : public GradientPaintStyle { +class CanvasLinearGradientPaintStyle : public GradientPaintStyle { public: static ErrorOr> create(FloatPoint p0, FloatPoint p1) { @@ -113,7 +113,7 @@ class CanvasLinearGradientPaintStyle final : public GradientPaintStyle { FloatPoint m_p1; }; -class CanvasConicGradientPaintStyle final : public GradientPaintStyle { +class CanvasConicGradientPaintStyle : public GradientPaintStyle { public: static ErrorOr> create(FloatPoint center, float start_angle = 0.0f) { @@ -133,7 +133,7 @@ class CanvasConicGradientPaintStyle final : public GradientPaintStyle { float m_start_angle { 0.0f }; }; -class CanvasRadialGradientPaintStyle final : public GradientPaintStyle { +class CanvasRadialGradientPaintStyle : public GradientPaintStyle { public: static ErrorOr> create(FloatPoint start_center, float start_radius, FloatPoint end_center, float end_radius) { @@ -190,7 +190,7 @@ class SVGGradientPaintStyle : public GradientPaintStyle { SpreadMethod m_spread_method { SpreadMethod::Pad }; }; -class SVGLinearGradientPaintStyle final : public SVGGradientPaintStyle { +class SVGLinearGradientPaintStyle : public SVGGradientPaintStyle { public: static ErrorOr> create(FloatPoint p0, FloatPoint p1) {