sequences containig object references
Bernd Daum
daum@dik.maschinenbau.tu-darmstadt.de
Mon, 27 Oct 1997 21:13:51 +0100 (MET)
I have some problems with sequences containig object references:
the idl - code:
interface Requirement_OB {
attribute string name;
};
typedef sequence<Requirement_OB> T_list;
interface List_of_Requirements_OB {
void get_Requirements(in string name, out T_list list);
};
C++ -code:
Corba-Client:
. .
T_list_var* list = new T_list();
objref->get_Requirements(name,list); //calling the server
Corba-server: implementation of the server method:
List_of_Requirements_OB::get_Requirements( const char * name, T_list *&
list) {
.
.
list = new T_list();
list->length(0);
for (CORBA::ULong i=0;iter.next()!=0;i++)
{
Requirement_OB_i *reqobj = new Requirement_OB_i(); //instantiation
of a new
// object -
inherits from
// the class
_sk_Requirement_OB
reqobj->name("temperature"); // populating the object
list->length(i+1);
(*list)[i] = reqobj; // inserting in the 'sequence'
}
}
If the corba - client calls the corba-server method ' get_Requirements',
the server prints the message:
Warning: try to release an object with reference count <= 0.
Has CORBA::release() been called more than once on an object reference?
and if the corba - client tries to invoke elements containing in the
argument-list the client crashes.
I'm afraid, i've made something wrong in the implementation of the
corba server (memory management) but i don't know what!
Is there anybody who knows a solution for my problem?
Thank you in advance.
Bernd Daum