Friday, 06 October 2006. Minor change to avoid (MSVC8) debug assertion
Oops - While running FG in Debug mode, to check some other code, I get a debug assertion in groundnetwork.cxx, which stops me getting to the code I want to see ;=(( A minor change in the order of the while() statements fixes this - output with diff -u --- F:\FGCVS\Flightgear\source\src\Airports\groundnetwork.cxx Thu Sep 21 13:15:54 2006 +++ F:\FG0910-4\Flightgear\src\Airports\groundnetwork.cxx Thu Oct 05 13:50:31 2006 @@ -681,7 +681,7 @@ // Search search if the current id alread has an entry // This might be faster using a map instead of a vector, but let's start by taking a safe route if (activeTraffic.size()) { - while ((i->getId() != id) && i != activeTraffic.end()) { + while ((i != activeTraffic.end()) && (i->getId() != id)) { i++; } } @@ -704,7 +704,7 @@ // Search search if the current id alread has an entry // This might be faster using a map instead of a vector, but let's start by taking a safe route if (activeTraffic.size()) { - while ((i->getId() != id) && i != activeTraffic.end()) { + while ((i != activeTraffic.end()) && (i->getId() != id)) { i++; } } @@ -722,7 +722,7 @@ // This might be faster using a map instead of a vector, but let's start by taking a safe route TrafficVectorIterator current, closest; if (activeTraffic.size()) { - while ((i->getId() != id) && i != activeTraffic.end()) { + while ((i != activeTraffic.end()) && (i->getId() != id)) { i++; } } @@ -760,7 +760,7 @@ TrafficVectorIterator i = activeTraffic.begin(); if (activeTraffic.size()) { - while ((i->getId() != id) && (i != activeTraffic.end())) + while ((i != activeTraffic.end()) && (i->getId() != id)) { i++; } @@ -876,7 +876,7 @@ TrafficVectorIterator i = activeTraffic.begin(); if (activeTraffic.size()) { - while ((i->getId() != id) && i != activeTraffic.end()) + while ((i != activeTraffic.end()) && (i->getId() != id)) { i++; } @@ -971,7 +971,7 @@ // This might be faster using a map instead of a vector, but let's start by taking a safe route if (activeTraffic.size()) { - while ((i->getId() != id) && i != activeTraffic.end()) { + while ((i != activeTraffic.end()) && (i->getId() != id)) { i++; } } @@ -989,7 +989,7 @@ // Search search if the current id has an entry // This might be faster using a map instead of a vector, but let's start by taking a safe route if (activeTraffic.size()) { - while ((i->getId() != id) && i != activeTraffic.end()) { + while ((i != activeTraffic.end()) && (i->getId() != id)) { i++; } } Simply, check if the iterator, i, is not at the end() FIRST, before doing the i->getId() check ;=)) the assertion message is something about dereferencing a pointer ... maybe you should not do i->getId() on the 'end()' member? I only got the assertion on the first of these changes, but copied the code to the others, just in case ... Regards, Geoff. EOF - fgd-009.doc _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ ------------------------------------------------------------------------- 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 Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel