I have the following if-else statement in my code, which I am using to display a value to the user on a GUI:
if (data.steering.fpTTGValid)
{
pFlightPlanTTGReadout->setValid();
pFlightPlanTTGReadout->update((int)data.steering.flightPlanTTG);
}
else
{
pFlightPlanTTGReadout->setInvalid();
}
When running the program in debug, and attaching to process in Visual Studio, if I hover the cursor over the data.steering.fpTTGValid variable in the 'if' statement, I can see that its value is true. My understanding is that this should mean that the code inside the subsequent {} executes, but the else statement should not execute.
However, as I continue to step through my code, I see that the data.steering.flightPlanTTG variable value stays at 0- suggesting that the update() function into which it is being passed has not executed. This variable also stays at 0 where it is displayed in the GUI, which would suggest that the else clause of the if statement has been called.
Since the fpTTGValid variable was true initially, my guess is that both the if and the else clause are being called- so that I never actually see a value displayed on the GUI, because the variable that would display it is set to 0 by the `setInvalid()' function.
Can anyone point out what I'm doing wrong here? Why isn't the value of the data.steering.flightPlanTTG variable being updated by the update() function even though the value of data.steering.fpTTGValid is true?
Aucun commentaire:
Enregistrer un commentaire