I have a problem with qDebug. When i try to log some value from a pointer it changes the value of my pointers.
I try to be more specific.
This is part of my code:
def_pipelines_laser->pipelines[0]->param_laser[0]->erosion = erosion;
def_pipelines_laser->pipelines[0]->param_laser[0]->planarity = CS_nominal/1000;
def_pipelines_laser->pipelines[0]->param_laser[0]->tolerance_minor = (CS_nominal/1000) - toll_cs;
def_pipelines_laser->pipelines[0]->param_laser[0]->tolerance_major = (CS_nominal/1000) + toll_cs;
qDebug() << "Laser Data " << def_pipelines_laser->pipelines[0]->param_laser[0]->erosion
<< " " << def_pipelines_laser->pipelines[0]->param_laser[0]->planarity
<< " " << def_pipelines_laser->pipelines[0]->param_laser[0]->tolerance_minor
<< " " << def_pipelines_laser->pipelines[0]->param_laser[0]->tolerance_major;
def_pipeline_laser is a "ParameterT" struct from FlatBuffer
struct ParametersT : public flatbuffers::NativeTable {
typedef Parameters TableType;
std::vector<std::unique_ptr<SmartDevice::Station::PipelineT>> pipelines{};
};
erosion and CS_nominal are two simple float which i assign to another flow parameter.
when i do the assignation everything is working fine, as soon as i hit the qdebug the values from my pointer (erosion, planarity, tolerance_minor, tolerance_major) they change to a value close to 0.
if I remove the qdebug or if I use the qdebug in this way everything works fine:
qDebug("Erosion = %s", std::to_string(def_pipelines_laser->pipelines[0]->param_laser[0]->erosion).c_str());
qDebug("Planarity = %s", std::to_string(def_pipelines_laser->pipelines[0]->param_laser[0]->planarity).c_str());
qDebug("Tolerance Min = %s", std::to_string(def_pipelines_laser->pipelines[0]->param_laser[0]->tolerance_minor).c_str());
qDebug("Tolerance Maj = %s", std::to_string(def_pipelines_laser->pipelines[0]->param_laser[0]->tolerance_major).c_str());
i add also two pictures from the debug to let you understand my problem
Can someone explain me why?