Bug #7677
Crash when WPaintDevice deallocates
Status:
Closed
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.
Updated by Roel Standaert over 2 years ago
- Status changed from New to Feedback
What platform is this on? How are you building Wt? Or are you using our binaries?
Updated by Ulf Johnsson over 2 years 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.
Updated by Roel Standaert over 2 years ago
- Status changed from Feedback to Resolved
I pushed a fix. We weren't properly recovering from font loading errors.
Updated by Roel Standaert over 1 year ago
- Description updated (diff)
- Status changed from Resolved to Closed