Skip to content

Commit

Permalink
LuaRef::pushToStack use current coroutine's stack, Fix SteveKChiu#131.
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Aug 20, 2016
1 parent d6f17a8 commit 8bf404e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions LuaIntf/LuaRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,15 @@ class LuaRef
/**
* Push value of this reference to Lua stack.
*/
void pushToStack() const
void pushToStack(lua_State* L1=nullptr) const
{
assert(L);
lua_rawgeti(L, LUA_REGISTRYINDEX, m_ref);
if (L1) {
lua_rawgeti(L1, LUA_REGISTRYINDEX, m_ref);
}
else {
assert(L);
lua_rawgeti(L, LUA_REGISTRYINDEX, m_ref);
}
}

/**
Expand Down Expand Up @@ -1321,7 +1326,7 @@ struct LuaTypeMapping <LuaRef>
static void push(lua_State* L, const LuaRef& r)
{
if (r.isValid()) {
r.pushToStack();
r.pushToStack(L);
} else {
lua_pushnil(L);
}
Expand Down

0 comments on commit 8bf404e

Please sign in to comment.