Project

General

Profile

Bug #7677

Crash when WPaintDevice deallocates

Added by Ulf Johnsson 3 months ago. Updated 2 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
08/06/2020
Due date:
% Done:

0%

Estimated time:

Description

Hi!

There is a crash that happends when WPaintDevice is deleted (I think).

To recreate set a weird font that cannot perform fontMetrics,

call painter.device()->fontMetrics(), catch the exception,

when the painter/device goes out of scope the crash occurs.

class PWid : public Wt::WPaintedWidget
{
public:
    PWid() : Wt::WPaintedWidget()
    {
        resize(400, 400);
    }

    void paintEvent(Wt::WPaintDevice* paintDevice) override
    {
        Wt::WPainter painter(paintDevice);

        Wt::WRectF r(0, 0, 400, 400);
        painter.fillRect(r, Wt::WColor(255, 0, 0));

        Wt::WFont f;
        f.setFamily(Wt::FontFamily::Default, "Wingdings");
        f.setSize(Wt::WLength(12, Wt::WLength::Unit::Pixel));
        painter.setFont(f);
        try {
            painter.device()->fontMetrics();
        }
        catch(...) {
        }
    }
};

class Application : public Wt::WApplication
{
public:
    Application(const Wt::WEnvironment& env) : Wt::WApplication(env) {}

    void initialize() override
    {
        root()->addNew<PWid>();
    }
};

BR, Ulf.

#1

Updated by Roel Standaert 3 months ago

  • Status changed from New to Feedback

What platform is this on? How are you building Wt? Or are you using our binaries?

#2

Updated by Ulf Johnsson 3 months ago

Roel Standaert wrote:

What platform is this on? How are you building Wt? Or are you using our binaries?

I am using Windows10, with Wt version 4.3.1. Binaries are built so that WPdfImage can be used.

#3

Updated by Roel Standaert 2 months ago

  • Status changed from Feedback to Resolved

I pushed a fix. We weren't properly recovering from font loading errors.

Also available in: Atom PDF