Fix memory leak when creating new Direct2D-based wxGraphicsContext.

ID2D1DCRenderTarget was leaked every time a wxD2DContext was created because a
raw pointer was given to wxCOMPtr<> which didn't take its ownership.

Use wxCOMPtr instead of the raw pointer to fix this and also fix more rare but
still possible leak in case of error.

This fixes out of memory errors and crashes in the drawing sample after a few
seconds of constant window resizing/repainting.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-09-14 01:00:11 +00:00
parent dc6830bded
commit 4d16d86821

View File

@@ -2575,7 +2575,7 @@ public:
protected:
void DoAcquireResource()
{
ID2D1DCRenderTarget* renderTarget;
wxCOMPtr<ID2D1DCRenderTarget> renderTarget;
D2D1_RENDER_TARGET_PROPERTIES renderTargetProperties = D2D1::RenderTargetProperties(
D2D1_RENDER_TARGET_TYPE_DEFAULT,
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED));