tst_QTextEdit: fix memleak in the MyPaintDevice helper
The constructor new'ed up a MyPaintEngine, but there was no destructor to delete the object again. Neither is ownership of the engine transferred out of the class, so the object was leaked. Fix by holding it in a unique_ptr. Amends 391e3aeef45efc937979b44c32147206e389a60b. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: I0c4da10d5a1659eceac0deba32cac757579e46c5 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
dd264cc9c0
commit
de2de7e12c
@ -2782,14 +2782,14 @@ namespace {
|
||||
class MyPaintDevice : public QPaintDevice
|
||||
{
|
||||
public:
|
||||
MyPaintDevice() : m_paintEngine(new MyPaintEngine)
|
||||
MyPaintDevice() : m_paintEngine(std::make_unique<MyPaintEngine>())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QPaintEngine *paintEngine () const override
|
||||
{
|
||||
return m_paintEngine;
|
||||
return m_paintEngine.get();
|
||||
}
|
||||
|
||||
int metric (QPaintDevice::PaintDeviceMetric metric) const override {
|
||||
@ -2816,7 +2816,7 @@ namespace {
|
||||
return 0;
|
||||
}
|
||||
|
||||
MyPaintEngine *m_paintEngine;
|
||||
std::unique_ptr<MyPaintEngine> m_paintEngine;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user