I would use the debugger and step over this code. Place a breakpoint on your Director line and then examine the scene variable that was created. Also, post what crashScene::createScene() is doing.
json = _dbManager->authUser(userText->getString().c_str());
this->buttonThinking(false);
_userData->loadUserDataStruct(json); <--- Crashes first line here when i tries to parse json
It keep going untill it crashes when trying to parse the invalid json
So, I made a quick test. I have 3-4 places in my code that i replaceScene, but it is always at the end of the code flow. So I added some code after the replaceScenes that were working fine and what happens is that the following code is again executed before the actual scene replace occurs. Is there a way to handle this as I need to replace scene only if a condition occurs ?
I would have handled the validation a bit differently. Maybe if you have the initial validation function return a bool instead of a Document, you can check against it being valid or not. if (validateJson()) { … continue parsing etc } else { handle error case}… or something of that nature.
I will have to change my whole logic here as Im having an object that communicates with the server. So the scene asks this object to get the response json = dbManager->getResponse. So the function will have to return… that leads to the same problem again. Or I will have to add this check to every server call i make from the scene itself
Yup, that’s something i was planning as a workaround, just I somehow feel replaceScene should occur right when its called. Thank you for helping with this!