mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Fixed Canvas:renderTo to restore the previous canvases if an error occurs in the passed function.
This commit is contained in:
@@ -51,12 +51,15 @@ int w_Canvas_renderTo(lua_State *L)
|
|||||||
luax_catchexcept(L, [&](){ graphics->setCanvas(canvas); });
|
luax_catchexcept(L, [&](){ graphics->setCanvas(canvas); });
|
||||||
|
|
||||||
lua_settop(L, 2); // make sure the function is on top of the stack
|
lua_settop(L, 2); // make sure the function is on top of the stack
|
||||||
lua_call(L, 0, 0);
|
int status = lua_pcall(L, 0, 0, 0);
|
||||||
|
|
||||||
graphics->setCanvas(oldcanvases);
|
graphics->setCanvas(oldcanvases);
|
||||||
|
|
||||||
for (Canvas *c : oldcanvases)
|
for (Canvas *c : oldcanvases)
|
||||||
c->release();
|
c->release();
|
||||||
|
|
||||||
|
if (status != 0)
|
||||||
|
return lua_error(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user