diff --git a/src/luaenginecore/luaengine/LuaEngine.cpp b/src/luaenginecore/luaengine/LuaEngine.cpp index 8c23558..ad85bb7 100644 --- a/src/luaenginecore/luaengine/LuaEngine.cpp +++ b/src/luaenginecore/luaengine/LuaEngine.cpp @@ -258,9 +258,10 @@ void LuaEngine::pushVariant(lua_State *L_p, const QVariant &variant) lua_createtable(L_p, 0, stringList.count()); int currentId = 1; for (const QString &string : stringList) { - lua_pushnumber(L_p, currentId); + char buffer[65]; + itoa(currentId, buffer, 10); lua_pushstring(L_p, string.toUtf8().data()); - lua_settable(L_p, -3); + lua_setfield(L_p, -2, buffer); currentId++; } } @@ -269,9 +270,10 @@ void LuaEngine::pushVariant(lua_State *L_p, const QVariant &variant) lua_createtable(L_p, 0, variantList.count()); int currentId = 1; for (const QVariant &variant : variantList) { - lua_pushnumber(L_p, currentId); + char buffer[65]; + itoa(currentId, buffer, 10); pushVariant(L_p, variant); - lua_settable(L_p, -3); + lua_setfield(L_p, -2, buffer); currentId++; } } @@ -281,9 +283,8 @@ void LuaEngine::pushVariant(lua_State *L_p, const QVariant &variant) QVariantMap::const_iterator it = variantMap.constBegin(); QVariantMap::const_iterator end = variantMap.constEnd(); while (it != end) { - lua_pushstring(L_p, it.key().toUtf8().data()); pushVariant(L_p, it.value()); - lua_settable(L_p, -3); + lua_setfield(L_p, -2, it.key().toUtf8().data()); it++; } }