These are chat archives for highfidelity/hifi

11th
Aug 2017
Nex-Pro
@Nex-Pro
Aug 11 2017 19:25
May I ask an API question ( relates to an open PR )
Seth Alves
@sethalves
Aug 11 2017 19:36
no harm in asking!
Jeff Moyes
@jmo7
Aug 11 2017 22:56

Does anybody know about the following: there is a QJsonObject that is visible to the scripting environment that I can read. However updating it seems tricky, according to some things I've read -- https://stackoverflow.com/questions/17034336/how-to-change-qjsonobject-value-in-a-qjson-hierarchy-without-using-copies and https://forum.qt.io/topic/25096/modify-nested-qjsonvalue/6

Apparently when you try to get a reference to some subobject inside of a QJsonObject it doesn't work because when you walk a JSON tree, you really aren't getting references to the keys and values of the subobjects, you are just given the values of the keys and values. Therefore, according to what I read, the only way to update some property of a subobject inside the QJsonObject is to replace the whole thing (which apparently runs into some pretty nasty memory issues).

Does anybody know if this is correct, and if it is, is there some other way to pull this off, that won't kill the memory?

Thanks

p.s. the QJsonObject in question is the Render object.

Jeff Moyes
@jmo7
Aug 11 2017 23:08
I may be misunderstanding this as I am still pretty unfamiliar with QT. I'm actually just working in javasript but when I try to reference Render['RenderMainView'] or Render.RenderMainView it returns undefined.
So I decided to run Object.keys(Render) to see what was available and I got objectName, cpuRunTime, enabled, destroyed(QObject*), destroyed(), objectNameChanged(QString), loaded(), newStats(), dirtyEnabled(), load(QJsonObject), toJSON(), load(QVariantMap), refresh(), getConfig(QString) - which would seem to be the QJsonObject and not just the javascript JSON object. (If I could just work with the Javascript version of the JSON object (use the normal javascript methods) this would be easy)