On Thu, Oct 23, 2008 at 1:11 AM, Alasdair Campbell
<[EMAIL PROTECTED]> wrote:
>
> As we can see, the address of _runway is set up within
> select_runway(airport, _runway), but is no longer valid (NULL) when
> control is returned to the caller. Hence the crash at the following
> line,
> 4545 runway.center.latitude = _runway->latitude();
>
> I don't know how to fix this.
Of course it isn't valid, inside the function it is only setting a
local variable (pass by value), and it does not return anything.
As the _runway argument is output only, there is no reason to pass it
as argument. Rather, the function should have a return type of
FGRunway*.
Try the attached patch.
--
Csaba/Jester
Index: mk_viii.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Instrumentation/mk_viii.hxx,v
retrieving revision 1.7
diff -u -r1.7 mk_viii.hxx
--- mk_viii.hxx 15 Aug 2008 18:48:12 -0000 1.7
+++ mk_viii.hxx 23 Oct 2008 00:16:58 -0000
@@ -1563,7 +1563,7 @@
double to_heading);
double get_azimuth_difference (const FGRunway *_runway);
- void select_runway (const FGAirport *airport, FGRunway *_runway);
+ FGRunway* select_runway (const FGAirport *airport);
void update_runway ();
void get_bias_area_edges (Position *edge,
Index: mk_viii.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Instrumentation/mk_viii.cxx,v
retrieving revision 1.10
diff -u -r1.10 mk_viii.cxx
--- mk_viii.cxx 11 Sep 2008 08:38:10 -0000 1.10
+++ mk_viii.cxx 23 Oct 2008 00:16:58 -0000
@@ -4489,10 +4489,10 @@
// This selection algorithm is not specified in [SPEC], but
// http://www.egpws.com/general_information/description/runway_select.htm
// talks about automatic runway selection.
-void
-MK_VIII::TCFHandler::select_runway (const FGAirport *airport,
- FGRunway *_runway)
+FGRunway*
+MK_VIII::TCFHandler::select_runway (const FGAirport *airport)
{
+ FGRunway* _runway = 0;
double min_diff = 360;
for (unsigned int r=0; r<airport->numRunways(); ++r) {
@@ -4504,6 +4504,7 @@
_runway = rwy;
}
} // of airport runways iteration
+ return _runway;
}
bool MK_VIII::TCFHandler::AirportFilter::pass(FGAirport *a)
@@ -4539,8 +4540,7 @@
has_runway = true;
- FGRunway* _runway;
- select_runway(airport, _runway);
+ FGRunway* _runway = select_runway(airport);
runway.center.latitude = _runway->latitude();
runway.center.longitude = _runway->longitude();
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel