Skip to content

Commit

Permalink
LibGfx: Fix dynamic_cast undefined behavior on macOS
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ananas-dev authored and kalenikaliaksandr committed Dec 18, 2024
1 parent d9ab68d commit 97768d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Libraries/LibGfx/PaintStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PaintStyle : public RefCounted<PaintStyle> {
virtual Color sample_color(IntPoint) const { return Color(); }
};

class SolidColorPaintStyle final : public PaintStyle {
class SolidColorPaintStyle : public PaintStyle {
public:
static ErrorOr<NonnullRefPtr<SolidColorPaintStyle>> create(Color color)
{
Expand Down Expand Up @@ -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<NonnullRefPtr<CanvasLinearGradientPaintStyle>> create(FloatPoint p0, FloatPoint p1)
{
Expand All @@ -113,7 +113,7 @@ class CanvasLinearGradientPaintStyle final : public GradientPaintStyle {
FloatPoint m_p1;
};

class CanvasConicGradientPaintStyle final : public GradientPaintStyle {
class CanvasConicGradientPaintStyle : public GradientPaintStyle {
public:
static ErrorOr<NonnullRefPtr<CanvasConicGradientPaintStyle>> create(FloatPoint center, float start_angle = 0.0f)
{
Expand All @@ -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<NonnullRefPtr<CanvasRadialGradientPaintStyle>> create(FloatPoint start_center, float start_radius, FloatPoint end_center, float end_radius)
{
Expand Down Expand Up @@ -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<NonnullRefPtr<SVGLinearGradientPaintStyle>> create(FloatPoint p0, FloatPoint p1)
{
Expand Down

0 comments on commit 97768d8

Please sign in to comment.