app_server: plug DrawState instance leak, other minor fixes

* OffscreenCanvas was not deleting its DrawState. Found thanks to
  the allocation tracking feature in libroot_debug (thanks mmlr!)

* Also a missing nothrow and a missing ref release in an error case
This commit is contained in:
Julian Harnath 2015-11-13 11:15:01 +01:00
parent bcc5cf7d29
commit 2193dcd799
2 changed files with 9 additions and 1 deletions

View File

@ -262,9 +262,10 @@ Canvas::BlendLayer(Layer* layer)
fDrawState->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
fDrawState->SetTransformEnabled(false);
AlphaMask* mask = new UniformAlphaMask(layer->Opacity());
AlphaMask* mask = new(std::nothrow) UniformAlphaMask(layer->Opacity());
if (mask == NULL) {
layerBitmap->ReleaseReference();
layer->ReleaseReference();
return;
}
@ -299,6 +300,12 @@ OffscreenCanvas::OffscreenCanvas(DrawingEngine* engine,
}
OffscreenCanvas::~OffscreenCanvas()
{
delete fDrawState;
}
void
OffscreenCanvas::ResyncDrawState()
{

View File

@ -91,6 +91,7 @@ class OffscreenCanvas : public Canvas {
public:
OffscreenCanvas(DrawingEngine* engine,
const DrawState& state, const IntRect& bounds);
virtual ~OffscreenCanvas();
virtual DrawingEngine* GetDrawingEngine() const { return fDrawingEngine; }