16.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit f98600be authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Extended LuaTableTreeModel to show SWIG type of LUA_TUSERDATA values if present.

refs #643
parent 27ba3923
......@@ -135,14 +135,22 @@ namespace campvis {
QString LuaTreeItemLeaf::getValue() const {
QString toReturn;
lua_State* L = _parentTable->getLuaVmState().rawState();
LuaStateMutexType::scoped_lock lock(_parentTable->getLuaVmState().getMutex());
if (_type == LUA_TSTRING || _type == LUA_TNUMBER) {
lua_State* L = _parentTable->getLuaVmState().rawState();
LuaStateMutexType::scoped_lock lock(_parentTable->getLuaVmState().getMutex());
_parentTable->pushField(_name);
toReturn = QString(lua_tostring(L, -1));
_parentTable->popRecursive();
}
else if (_type == LUA_TUSERDATA) {
auto mt = _parentTable->getMetatable(_name);
if (mt) {
mt->pushField(".type");
toReturn = "[" + QString(lua_tostring(L, -1)) + "]";
mt->popRecursive();
}
}
return toReturn;
}
......
......@@ -52,10 +52,11 @@ namespace campvis {
virtual bool isValid() override;
virtual void callInstanceMethod(const std::string& name) override;
protected:
virtual void pushField(const std::string& name) override;
virtual void popRecursive() override;
protected:
virtual void populateValueMap() override;
virtual LuaTable* getParentTable() override;
};
......
......@@ -30,7 +30,6 @@
#include <string>
#include "scripting/swigluarun.h"
#include "scripting/glue/globalluatable.h"
#include "scripting/glue/metatableluatable.h"
#include "tbb/recursive_mutex.h"
extern "C" {
......
......@@ -29,9 +29,10 @@ namespace campvis {
virtual bool isValid() override;
virtual void callInstanceMethod(const std::string& name) override;
protected:
virtual void pushField(const std::string& name) override;
virtual void popRecursive() override;
protected:
virtual void populateValueMap() override;
virtual LuaTable* getParentTable() override;
......
......@@ -53,9 +53,10 @@ namespace campvis {
virtual bool isValid() override;
virtual void callInstanceMethod(const std::string& name) override;
protected:
virtual void pushField(const std::string& name) override;
virtual void popRecursive() override;
protected:
virtual void populateValueMap() override;
virtual LuaTable* getParentTable() override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment