[omniORB] _CORBA_ObjRef_Member problem in omniORB 2.8.0

Alf Nilsson alf.nilsson@coderight.se
Wed, 05 Dec 2001 21:56:31 +0100


Hi,

I'm having a bit of a problem assigning _var objects to _member 
objects...sometimes.

View the following:

//IDL
module Test
{
   interface TestInterface
   {
     void AMethod();
   };

   struct TestStruct
   {
     TestInterface mTestInterface;
   };
};

//C++
Test::TestInterface_var tTestInterfaceVar = (...) //Locate an instance from 
somewhere

//First case
Test::TestStruct tNewStruct;
tNewStruct.mTestInterface = tTestInterfaceVar;

When assigning the _var to the _member a copy constructor is called upon: 
inline T_member& operator= (const T_var& p)
So far things are OK.

//Second case
tNewStruct.mTestInterface = tTestInterfaceVar;

But in some places in the program the _var does something I do not 
understand, it calls upon the following method: inline operator T_ptr () 
const  { return pd_objref; }.
This causes the following copy constructor to be called upon : inline 
T_member& operator= (T_ptr p)

Now this tends to make my refcount to go berserk. Later on in the program I 
try to copy the struct, this leads to an error & halts the debugger.

To solve the problem with my refcount error I have made a change in the 
code (In the places where the _var thinks I'm casting it to a _ptr) that 
makes me feel a bit uneasy...
//Solution(?)
tNewStruct.mTestInterface = 
tTestInterfaceVar->_duplicate(tTestInterfaceVar); //This solves the 
refcount problem.

So can someone please tell me why the CORBA_ObjRef_Member is treated 
differently in the 2nd case?

OS = win2k, sp2
Compiler = Visial C++, sp4

Thanks in advance,
Alf Nilsson
CodeRight AB