From 4d16d868210fd69cd5923b2dde60bc235f680d29 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 14 Sep 2014 01:00:11 +0000 Subject: [PATCH] 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 --- src/msw/graphicsd2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index 302f160437..521a2cc0b0 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -2575,7 +2575,7 @@ public: protected: void DoAcquireResource() { - ID2D1DCRenderTarget* renderTarget; + wxCOMPtr renderTarget; D2D1_RENDER_TARGET_PROPERTIES renderTargetProperties = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED));