[solved] script not re-evaluating
I have a quite large qt app and want to avoid re-compiling every time i want to change a configuration parameter.
The only way i have to refresh the contents is to do a clean all / run, which defeats the purpose (because i'm back to square 1 at recompiling).
I tried pushing and popping contexts in QScriptEngine to no avail, and I tried googling as much as possible about scripts not reloading but it seems like there's very little and not entirely relevant.
I'd be extremely grateful if anybody can help out.
This is what I'm doing:
Config appConfig; appConfig.debug = false; appConfig.appname = "test"; QScriptValue cnf = engine.newQObject(&appConfig); QScriptContext * ctx = engine.pushContext(); ctx->activationObject().setProperty("config", cnf); engine.evaluate(contents, configFilename); qDebug() << "cnf: " << cnf.property("debug").toBoolean() << ", appname: " << cnf.property("appname").toString(); engine.popContext();@
For the record, I resolved the problem.
The problem was that the config file was loaded as a resource (using the ":" accessor). Obviously this causes qt to "bake" the resource and not reload its contents, which makes sense.
Using an absolute path resolved the problem.
Hi and welcome to devnet,
Glad you found out and thanks for sharing your findings.
Can you also please update the thread title prepending [solved] so other forum users may know a solution has been found :)
Happy coding !