Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion winrt/lib/drawing/DeviceContextPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ DeviceContextLease DeviceContextPool::TakeLease()

if (m_deviceContexts.empty())
{
//Store a local copy of the non-null device pointer before unlocking.
ComPtr<ID2D1Device1> localDevice(m_d2dDevice);
//Release lock before creating the device context to avoid potential deadlock scenarios.
lock.unlock();
ComPtr<ID2D1DeviceContext1> deviceContext;
ThrowIfFailed(m_d2dDevice->CreateDeviceContext(
ThrowIfFailed(localDevice->CreateDeviceContext(
D2D1_DEVICE_CONTEXT_OPTIONS_NONE,
&deviceContext));
return DeviceContextLease(this, std::move(deviceContext));
Expand Down