We have created a scriptable state machine using the QJSEngine but are now running into an issue. We use a script which is called every 500 miliseconds to poll during idle in order to trigger a transition if required.
If we keep the system running in idle for a while we keep getting an issue on the call to one of our registered C++ methods.
The issue is as follows: We have a method registered to the QJSEngine which has two parameters. The first is a const QString& "key" and the second being a QJSValue "value". Sometimes when we call this method the "value" parameter will be undefined.
This behaviour seems to be happening at quite random intervals, sometimes after about 5 minutes of running the system, sometimes 20, sometimes 2 hours. I have not been able to figure out what the reason for these random intervals is.
In my debugging efforts I have changed the call so it's just a string literal coming in from the JS side, doing this still made the bug reproduce. I have also changed the "value" parameter's type to a const QJSValue& and this has only had the effect of changing it from a QJSValue "undefined" to a QJSValue::Int 0.
I need help figuring out what the cause of this issue is as this call is one of the core elements of our system and we can't miss any of these values.
Below are snippets from the JS and C++ code: