Hi Maik,
It looks like I completely overlooked your message yesterday. I've been
playing with your idea a bit. Some more comments below.
On Wednesday 15 November 2006 19:53, Maik Justus wrote:
> Hi,
>
> I built a version with debug info only for this file and got, as
> expected, normal performance.
> The problem is in line 807:
> if (i != current)
> I have not much experience with overloaded comparators, but it seems to
> me, that not the "pointers" are compared in this case, but the complete
That is not what is supposed to happen: I'm not comparing whether the two
objects the iterators are pointing to are identical or not, but whether the
two iterators themselves are pointing to the same object.
'current' is pointing to a valid object (which is established at the beginning
of the function, and "i" is also pointing to a valid object (because it
iterates between towerController->getActiveTraffic().begin(); and
towerController->getActiveTraffic().end()
the overloaded object comparison would be something like:
if ((*current) == (*i))
I've added a bool operator == (const FGTrafficRecord &right) const {return id
== right.id;} as you suggested, and added a few debug warning messages to it
to see whether it got called, which it didn't. So, I'm pretty sure that the
code above is actually just comparing whether the two iterators are pointing
to the same object or not.
> structure. But "current" holds an invalid pointer in its structure:
> (((*(current)._Myptr).runway))._Bx
I did find out that I never assigned a value to runway, in case of traffic
that is on the ground network (whereas I do assign a runway for traffic that
is waiting for take-off).
> I don't know how this can happen, that the string "runway" contains a
> invalid pointer, but this seems to cause the crash. Maybe another
> pointer writing on this pointer? Or did you copy the address of this
> FGTrafficRecord (or of the string runway) and call the destructor?
Hmm, no, not likely: I'm not acessing the runway string other than by copying
a value into it. So assuming stl string has a correct copy constructor, this
should work out okay.
>
> For performance reason I would suggest to add an operator == to class
> FGTrafficRecord, esp.:
> bool operator == (const FGTrafficRecord &right) const {return id ==
> right.id;}
> if "id" is sufficient to compare two FGTrafficRecords.
>
Yes, that would be sufficient, is you were comparing objects, but here is
really is only comparing pointers.
Still, the code still seems to crash on your system. so something's gotta be
wrong.
Cheers,
Durk
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel