From: Kevin Meinert (kevn++at++vrac.iastate.edu)
Date: 05/23/2001 12:56:00
pfGreetings,
I've found a difference between C and C++ versions of the
unref-delete functions in Performer 2.4:
- pfUnrefDelete(pfGroup*)
- pfGroup::unrefDelete().
In the man page, the descriptions for the two versions are identical, but
the actual behavior is different. (a possible bug in performer?)
Here is the symptom:
- pfUnrefDelete(pfGroup*) decrements the refcount of the given
group and all child refcounts.
- pfGroup::unrefDelete() decrements the refcount of the given
group BUT DOES NOT decrement the child refcounts.
Why would these two functions behave differently? If this isn't a bug, I
would really appreciate if someone could help me understand.
See my test code below followed by its output:
++at++--++at++---++at++---++at++----++at++-----++at++------++at++------++at++-----++at++----++at++---++at++---++at++--++at++
Kevin Meinert __ _ __
http://www.vrac.iastate.edu/~kevn \ || \| \ / `
Virtual Reality Applications Center \ ||.-'|--\
Howe Hall, Iowa State University, Ames Iowa \|| \| \`__,
-----------------------------------------------------------
void test1()
{
pfGroup* group1 = new pfGroup;
pfGroup* group2 = new pfGroup;
pfGroup* group3 = new pfGroup;
pfGroup* group4 = new pfGroup;
pfGroup* group5 = new pfGroup;
// group2 - group5
// group1 /
// \ group3 - group4
//
group1->addChild( group2 );
group1->addChild( group3 );
group2->addChild( group4 );
group3->addChild( group5 );
group1->ref();
cout<<"group1: "<<group1->getRef()<<"\n"<<flush;
cout<<"group2: "<<group2->getRef()<<"\n"<<flush;
cout<<"group3: "<<group3->getRef()<<"\n"<<flush;
cout<<"group4: "<<group4->getRef()<<"\n"<<flush;
cout<<"group5: "<<group5->getRef()<<"\n"<<flush;
int result = pfUnrefDelete( group1 );
switch (result)
{
case TRUE:
cout<<"result: object was deleted\n"<<flush;
break;
case FALSE:
cout<<"result: object was not deleted\n"<<flush;
break;
case -1:
cout<<"result: the object is not a pfMemory\n"<<flush;
break;
}
cout<<"group1: "<<group1->getRef()<<"\n"<<flush;
cout<<"group2: "<<group2->getRef()<<"\n"<<flush;
cout<<"group3: "<<group3->getRef()<<"\n"<<flush;
cout<<"group4: "<<group4->getRef()<<"\n"<<flush;
cout<<"group5: "<<group5->getRef()<<"\n"<<flush;
cout<<"\n"<<flush;
}
void test2()
{
pfGroup* group1 = new pfGroup;
pfGroup* group2 = new pfGroup;
pfGroup* group3 = new pfGroup;
pfGroup* group4 = new pfGroup;
pfGroup* group5 = new pfGroup;
// group2 - group5
// group1 /
// \ group3 - group4
//
group1->addChild( group2 );
group1->addChild( group3 );
group2->addChild( group4 );
group3->addChild( group5 );
group1->ref();
cout<<"group1: "<<group1->getRef()<<"\n"<<flush;
cout<<"group2: "<<group2->getRef()<<"\n"<<flush;
cout<<"group3: "<<group3->getRef()<<"\n"<<flush;
cout<<"group4: "<<group4->getRef()<<"\n"<<flush;
cout<<"group5: "<<group5->getRef()<<"\n"<<flush;
int result = group1->unrefDelete();
switch (result)
{
case TRUE:
cout<<"result: object was deleted\n"<<flush;
break;
case FALSE:
cout<<"result: object was not deleted\n"<<flush;
break;
case -1:
cout<<"result: the object is not a pfMemory\n"<<flush;
break;
}
cout<<"group1: "<<group1->getRef()<<"\n"<<flush;
cout<<"group2: "<<group2->getRef()<<"\n"<<flush;
cout<<"group3: "<<group3->getRef()<<"\n"<<flush;
cout<<"group4: "<<group4->getRef()<<"\n"<<flush;
cout<<"group5: "<<group5->getRef()<<"\n"<<flush;
cout<<"\n"<<flush;
}
///////////////////////////////////////////////////
// output:
///////////////////////////////////////////////////
group1: 1
group2: 1
group3: 1
group4: 1
group5: 1
result: object was deleted
group1: 0
group2: 0
group3: 0
group4: 0
group5: 0
group1: 1
group2: 1
group3: 1
group4: 1
group5: 1
result: object was deleted
group1: 0
group2: 1
group3: 1
group4: 1
group5: 1
This archive was generated by hypermail 2b29 : Wed May 23 2001 - 12:56:10 PDT