Re: [Flightgear-devel] Object scope help

2011-10-11 Thread ThorstenB
On 11.10.2011 23:31, Robbo wrote:
 TaRadar* _taradar_node = (TaRadar*) globals-get_subsystem(
 taradar);

 Now then, if TaRadar::getAngle() has the following fixed code:
 return 10;
 everything works ok, but if the method returns an object variable:
 return _angle;
 I get a segmentation fault.

That means _taradar_node is NULL. Calling _taradar_node-getAngle() is 
illegal if _taradar_node=0. However, if the method you're calling 
doesn't access the object itself, but just returns a constant (return 
10), then nothing happens (lucky!). Add a check if (_taradar_node!=0) 
... and see why the pointer is NULL.

cheers,
Thorsten

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Object scope help

2011-10-11 Thread Csaba Halász
On Tue, Oct 11, 2011 at 11:31 PM, Robbo robbo_b...@hotmail.com wrote:

 The classes are instantiated within instrument_manager:

     } else if ( name == taradar ) {
     set_subsystem( id, new TaRadar( node ), 1 );

Notice that the subsystem will be registered using the id not the
name. So make sure you are using the correct value when retrieving
it, below:

 TaRadar* _taradar_node = (TaRadar*) globals-get_subsystem(taradar);

-- 
Csaba/Jester

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Object scope help

2011-10-11 Thread Michael Robson

Thorsten,

Thanks for your prompt reply.

I get that the pointer is NULL, but I do not understand why!

I believe that I have called the correct method to return a pointer to the 
object.  And since I know that the object has been instantiated (since i get a 
cout message to tell me and also i can see the object doing what its supposed 
to be doing on screen).

Do you have any idea why this object may be null? have i correctly registered 
the instrument? does the instrument not persist until program completion? How 
do I correctly obtain a pointer to this object if this is not the correct way?

Thanks

Robbo

 Date: Tue, 11 Oct 2011 23:42:42 +0200
 From: bre...@gmail.com
 To: flightgear-devel@lists.sourceforge.net
 Subject: Re: [Flightgear-devel] Object scope help
 
 On 11.10.2011 23:31, Robbo wrote:
  TaRadar* _taradar_node = (TaRadar*) globals-get_subsystem(
  taradar);
 
  Now then, if TaRadar::getAngle() has the following fixed code:
  return 10;
  everything works ok, but if the method returns an object variable:
  return _angle;
  I get a segmentation fault.
 
 That means _taradar_node is NULL. Calling _taradar_node-getAngle() is 
 illegal if _taradar_node=0. However, if the method you're calling 
 doesn't access the object itself, but just returns a constant (return 
 10), then nothing happens (lucky!). Add a check if (_taradar_node!=0) 
 ... and see why the pointer is NULL.
 
 cheers,
 Thorsten
 
 --
 All the data continuously generated in your IT infrastructure contains a
 definitive record of customers, application performance, security
 threats, fraudulent activity and more. Splunk takes this data and makes
 sense of it. Business sense. IT sense. Common sense.
 http://p.sf.net/sfu/splunk-d2d-oct
 ___
 Flightgear-devel mailing list
 Flightgear-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/flightgear-devel
  --
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] Object scope help

2011-10-11 Thread Robbo
Csaba,

Thanks, that makes complete sense, I did not spot that the id may be how it
is registered.

However, I have checked what value comes back from id and it is
'instrument-1-taradar', so i changed my call to:

globals-get_subsystem(instrument-1-taradar);

but this is still returning NULL!

i print out some useful info from my code:

log: set_subsystem: taecho: instrument-0-taecho
log: TaEcho constructor called
log: set_subsystem: taradar: instrument-1-taradar
log: TaRadar constructor called
log: TaRadar isnull = YES

Any other ideas why this is NULL?

Cheers

Robbo


2011/10/11 Csaba Halász csaba.hal...@gmail.com

 On Tue, Oct 11, 2011 at 11:31 PM, Robbo robbo_b...@hotmail.com wrote:
 
  The classes are instantiated within instrument_manager:
 
  } else if ( name == taradar ) {
  set_subsystem( id, new TaRadar( node ), 1 );

 Notice that the subsystem will be registered using the id not the
 name. So make sure you are using the correct value when retrieving
 it, below:

  TaRadar* _taradar_node = (TaRadar*) globals-get_subsystem(taradar);

 --
 Csaba/Jester


 --
 All the data continuously generated in your IT infrastructure contains a
 definitive record of customers, application performance, security
 threats, fraudulent activity and more. Splunk takes this data and makes
 sense of it. Business sense. IT sense. Common sense.
 http://p.sf.net/sfu/splunk-d2d-oct
 ___
 Flightgear-devel mailing list
 Flightgear-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/flightgear-devel


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel