mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Changed luax_pushtype to retain the pushed object itself, but only if the object isn't in the Lua state already.
Previously, calling e.g. love.graphics.getFont() 10,000 times would retain the object 10,000 times (and release it 10,000 times when the Font object was garbage-collected in the Lua state.) Now it will only retain it once and release it once.
This commit is contained in:
@@ -125,8 +125,8 @@ int Physics::newPolygonShape(lua_State *L)
|
||||
}
|
||||
|
||||
PolygonShape *p = new PolygonShape(s);
|
||||
|
||||
luax_pushtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, p);
|
||||
p->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ int Physics::newChainShape(lua_State *L)
|
||||
|
||||
ChainShape *c = new ChainShape(s);
|
||||
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, c);
|
||||
c->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user