Hi!

After a small research, I ended up on this group, that discussed the exact 
problem I am currently experiencing.
Unfortunately, the solution could not be applied to my case.

By posting on this old thread, I am hoping somebody could give me some more 
hints in order to resolve my situation.

Please, find bellow the message I posted on another dev forum:
 

> Currently using protobuf under its 2.5.0 version, I am stuck with a 
> problem I am struggling to resolve. First of all, the following .proto 
> files represent the messages I am dealing with :
>
> MacroMission.proto
> message MacroMission{
>     required int32 timeWithoutCom=1;
>     required string name=2;
>     required Phase failSafePhase=3;
>     repeated Phase phases=4;}
> message Phase{
>     optional Survey survey=1;}
> message Survey{
>     repeated Segment trajectory=1;
>         required string sonarPreset=4;}
> message Segment{
>         required WayPoint start=1;
>         required WayPoint end=2;}Common.proto
> message WayPoint{
>    required GeoPoint pos = 1;   // Not relevant
>    optional string label = 2 ;}
>
> The aim of the software is to fill a MacroMission message. I am working 
> under Windows 7, with C++/Qt and minGW compiler, using the protobuf library 
> within Qt Plugin projects (a message is shared between two distinct 
> plugins, a « creator » and a « filler »).
>
> My problem is : whenever I try to assign a value to a field of string 
> type, all the other string fields are taking the same value. My first guess 
> was that, somehow, all these fields had the same address in memory, which 
> turned out true. Concerned about the good initialization of the messages, I 
> double checked all the process for creating the MacroMission. It could be 
> best described by the following lines :
>
> Classe A – Plugin 1
>         ::pb::MacroMission mission;
>
>         mission.set_name(rMissionName.toStdString());
>
>
>         mission.set_timewithoutcom(timeWithoutCom);
>
>
>         foreach(MissionClass)
>         {
>             ::pb::Phase * missionPhase = mission.add_phases();
>             MissionClass->FillPhase(missionPhase);
>         }
> MissionClass – Plugin 2
>     FillPhase methode (TnamedSegment is a support class for segment data 
> access)
>
>     ::pb::Survey * survey = missionPhase->mutable_survey();  
>
>     for(int segmentRank = 0 ; segmentRank < 
> surveyParams.getSegments().count() ; ++segmentRank)
>     {
>         TNamedSegment segment = surveyParams.getSegments()[segmentRank];
>
>         qDebug() << "Adding one segment :";
>
>         ::pb::Segment* pb_segment = survey->add_trajectory();
>
>         
> pb_segment->mutable_start()->set_label(QString("WP_%1_start").arg(segmentRank).toStdString());
>         
> pb_segment->mutable_start()->mutable_pos()->set_latitude(segment.startWP.latitude);
>         
> pb_segment->mutable_start()->mutable_pos()->set_longitude(segment.startWP.longitude);
>
>         
> pb_segment->mutable_end()->set_label(QString("WP_%1_end").arg(segmentRank).toStdString());
>         
> pb_segment->mutable_end()->mutable_pos()->set_latitude(segment.endWP.latitude);
>         
> pb_segment->mutable_end()->mutable_pos()->set_longitude(segment.endWP.longitude);
> }
>
>     survey->set_sonarpreset(surveyParams.getSonarPreset().toStdString());
>
> In the end, nothing comes out of the blue in this code. But, as I 
> previously said, all the protobuf labels/names in the messages have the 
> same address. Therefore, they will all end up with the same value, the one 
> of the last field set (in this case, the value of SonarPreset). I have been 
> able to solve a little tiny part of the problem by using the 
> set_allocated_var method, but in the end, the major part of the problem 
> remains unchanged.
>
> After several hours of internet researches, many regenerations/rebuilds of 
> the protobuf messages and of the project in which they are used, memory 
> allocation double checks, and protobuf library help documentation readings, 
> I come to you in order to know if, by any change, someone would have the 
> beginning of a solution to my problem.
>
> I did a small unit test program which only fill the protobuff message in a 
> single "main.cpp" file, and everything works fine...
>
> Thank you in advance for any answer.
>
> PS : Please let me know if you need any further information in order to 
> clarify the problem.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to