Commit 7c930589 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Avoid some common invalid context accesses.

Unfortunately there are plenty of other places left. Perhaps we should consider creating our own window when the context becomes invalid and making the context current on that instead.
parent 135f3641
......@@ -4369,6 +4369,12 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfac
}
context = context_acquire(This, (IWineD3DSurface *)target, CTXUSAGE_CLEAR);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping clear.\n");
return WINED3D_OK;
}
target->get_drawable_size(context, &drawable_width, &drawable_height);
......@@ -5842,6 +5848,13 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
else if (!surface_is_offscreen(dst_surface)) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
else context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping blit.\n");
return;
}
gl_info = context->gl_info;
if (!surface_is_offscreen(src_surface))
......
......@@ -596,6 +596,12 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
This->isInDraw = TRUE;
context = context_acquire(This, This->render_targets[0], CTXUSAGE_DRAWPRIM);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping draw.\n");
return;
}
if (This->stencilBufferTarget) {
/* Note that this depends on the context_acquire() call above to set
......
......@@ -223,6 +223,12 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride);
context = context_acquire(This->device, This->backBuffer[0], CTXUSAGE_RESOURCELOAD);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping present.\n");
return WINED3D_OK;
}
/* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */
if (This->device->bCursorVisible && This->device->cursorTexture)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment