[omniORB] My program crashes when I try to dereference an object from a sequence

Lane, Frank L frank.l.lane at boeing.com
Tue Oct 28 12:36:54 GMT 2008


Hi,

Firstly, Martin, thank you!

I'm going to go over the examples better, and look into Messrs. Henning
and Vinoski tome (it's humongous).

I notice that most of what you talk about on this list are 'advanced'
topics.  However, with that in mind, as a beginner I have no option
other than ask beginner questions.

If no one answers it won't hurt my feelings and I do appreciate it
should anyone deign to favor me with a response.  Martin really pulled
my irons out of the fire.  In my own mind my biggest problem is getting
my head wrapped around the terminology.

In code layman's terms, what is the difference between <interface>_impl
* and <interface>_ptr?  They are related, I'm hoping?  They are
obviously not as interchangeable as I'd imagined.

Based on Martin's response I'm assuming <interface>_impl * is known as
an object implementation?

Is <interface>_ptr what is referred to in omni documentation as an
"object reference"?

Double thank you to Martin because I was unaware that the call on
'TheCustomer' didn't involve CORBA.

Thank You For Your Time,
Frank

-------------------

Date: Tue, 28 Oct 2008 11:15:56 +0100
From: Martin Trappel <0xCDCDCDCD at gmx.at>
Subject: Re: [omniORB] My program crashes when I try to dereference an
	object	from a sequence
To: omniorb-list at omniorb-support.com
Message-ID: <4906E65C.6060001 at gmx.at>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Lane, Frank L wrote:
> Hi,
> 
> My program is crashing and I don't understand why, will someone please

> tell me what I'm doing wrong?
> Visual Studio 2008, XP, OmniORB 4.1.3
> 
>(...) 
>    Customer_impl * TheCustomer
>       = new Customer_impl (CustomerName, CustomerAccount);
> 
>    cout << "New customer created, " << TheCustomer->Name()
>       << ", " << TheCustomer->Account() << endl;
> 
>    CORBA::Long size = _Customers.length();
>    _Customers.length(size+1);
>    _Customers[size] = (Customer_ptr)TheCustomer;
> 
Never, ever use c-style casts.
What you probably wanted to do was:
_Customers[size] = TheCustomer->_this();


>    if (CORBA::is_nil(_Customers[0]))
>       cout << "The newly created seq member is nil?" << endl;
>    else {
>       cout << "_Customers[0]: " << _Customers[0] << endl;
>       cout << "TheCustomer: " << TheCustomer << endl;
>    cout << "TheCustomer data, " << TheCustomer->Name()
>       << ", " << TheCustomer->Account() << endl;
> 
You are aware that the calls on TheCustomer are direct calls on the
implementation object, and won't involve any CORBA?

> !!!!! ----- Here is where it is crashing -----!!!!!!
> !!!!! ----- The instant I try to get data back out of the sequence it 
> crashes ----- !!!!!!!
>    Customer_var temp = (Customer_ptr)_Customers[0];
Never, ever use c-style casts.
You should use a _ptr type for the temp or duplicate() the sequence
element!

>    cout << "The sequence data, " << temp->Name()
>       << ", " << (*temp).Account() << endl;
>       //cout << "New customer created, " << _Customers[0]->Name() << 
> endl;
>    }
> 
> 
>    return Customer::_duplicate((Customer_ptr)TheCustomer);
> 
Never, ever use c-style casts.


1) Look at the omniORB examples. example #1 will show you how to
correctly instantiate and the use an object.

2) After looking at the examples, get "Adavced CORBA programming with 
C++" by Henning,Vinoski


br,
Martin


------------------------------

_______________________________________________
omniORB-list mailing list
omniORB-list at omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list


End of omniORB-list Digest, Vol 66, Issue 17
********************************************



More information about the omniORB-list mailing list