Skip to content

Commit

Permalink
Fixed some issues with PropIndex that was causing various problems
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfug committed May 2, 2020
1 parent 40f75ff commit 405d96c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ServerCore/lua_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ int lua_object::luaGet( lua_State *L )
{
if( P->type() == QVariant::Map )
{
return( lua_prop::lua_pushpropindex( L, P ) );
return( lua_prop::lua_pushpropindex( L, O->id(), P ) );
}
else
{
Expand Down
13 changes: 8 additions & 5 deletions ServerCore/lua_prop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "changeset/propertysetwrite.h"
#include "changeset/propertysetchange.h"
#include "changeset/connectionnotify.h"
#include "changeset/objectsetproperty.h"

const char *lua_prop::mLuaName = "moo.prop";
const char *lua_prop::mLuaPropIndexName = "moo.propindex";
Expand Down Expand Up @@ -689,7 +690,7 @@ int lua_prop::luaValue( lua_State *L )
// Property Index


int lua_prop::lua_pushpropindex( lua_State *L, Property *pProperty )
int lua_prop::lua_pushpropindex( lua_State *L, ObjectId pObjectId, Property *pProperty )
{
luaPropIndex *P = reinterpret_cast<luaPropIndex *>( lua_newuserdata( L, sizeof( luaPropIndex ) ) );

Expand All @@ -701,6 +702,7 @@ int lua_prop::lua_pushpropindex( lua_State *L, Property *pProperty )
}

P->mProperty = pProperty;
P->mObjectId = pObjectId;
P->mIndex = Q_NULLPTR;

luaL_getmetatable( L, mLuaPropIndexName );
Expand All @@ -709,7 +711,7 @@ int lua_prop::lua_pushpropindex( lua_State *L, Property *pProperty )
return( 1 );
}

int lua_prop::lua_pushpropindex( lua_State *L, Property *pProperty, const lua_prop::luaPropIndexPath &pPath )
int lua_prop::lua_pushpropindex( lua_State *L, ObjectId pObjectId, Property *pProperty, const lua_prop::luaPropIndexPath &pPath )
{
luaPropIndex *P = reinterpret_cast<luaPropIndex *>( lua_newuserdata( L, sizeof( luaPropIndex ) ) );

Expand All @@ -721,6 +723,7 @@ int lua_prop::lua_pushpropindex( lua_State *L, Property *pProperty, const lua_pr
}

P->mProperty = pProperty;
P->mObjectId = pObjectId;
P->mIndex = new luaPropIndexPath( pPath );

luaL_getmetatable( L, mLuaPropIndexName );
Expand Down Expand Up @@ -819,7 +822,7 @@ int lua_prop::luaPropIndexGet( lua_State *L )

if( V.type() == QVariant::Map || V.type() == QVariant::List )
{
return( lua_pushpropindex( L, P, Path ) );
return( lua_pushpropindex( L, LP->mObjectId, P, Path ) );
}

return( luaL_pushvariant( L, V ) );
Expand Down Expand Up @@ -895,7 +898,7 @@ int lua_prop::luaPropIndexSet( lua_State *L )
NewV = Index.first;
}

P->setValue( NewV );
Command->changeAdd( new change::ObjectSetProperty( ObjectManager::o( LP->mObjectId ), P->name(), NewV ) );
}
catch( const mooException &e )
{
Expand Down Expand Up @@ -969,7 +972,7 @@ int lua_prop::luaPropIndexClear(lua_State *L)
NewV = Index.first;
}

P->setValue( NewV );
Command->changeAdd( new change::ObjectSetProperty( ObjectManager::o( LP->mObjectId ), P->name(), NewV ) );
}
catch( const mooException &e )
{
Expand Down
5 changes: 3 additions & 2 deletions ServerCore/lua_prop.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ class lua_prop
typedef struct luaPropIndex
{
Property *mProperty;
ObjectId mObjectId;
luaPropIndexPath *mIndex;
} luaPropIndex;

static int lua_pushpropindex( lua_State *L, Property *pProperty );
static int lua_pushpropindex( lua_State *L, ObjectId pObjectId, Property *pProperty );

static int lua_pushpropindex( lua_State *L, Property *pProperty, const luaPropIndexPath &pPath );
static int lua_pushpropindex( lua_State *L, ObjectId pObjectId, Property *pProperty, const luaPropIndexPath &pPath );

static luaPropIndex *propindex( lua_State *L, int pIndex = 1 );

Expand Down

0 comments on commit 405d96c

Please sign in to comment.