Why does SoNode::copy() require a ref count?

Why does SoNode::copy() require a ref count?

Post by Curtis.N.Bingh » Tue, 20 Aug 1996 04:00:00



Refcounting really bites when you aren't looking! :-)

Does anyone have any idea what the SoNode::copy() method does such
that it cannot copy nodes with a refcount of 0 without destroying
them?  

Curtis

--

_________________________________________________________________________

User Interface Engineer | Room #55D-220            | (610) 712-2432      |
        KB7YAM          | 1247 S. Cedar Crest Blvd | (610) 712-2790 FAX  |
                        | Allentown, PA  18103     |                     |

                 If you are not part of the solution,
                   you are part of the precipitate!

 
 
 

Why does SoNode::copy() require a ref count?

Post by Paul S. Strau » Wed, 21 Aug 1996 04:00:00


|> Refcounting really bites when you aren't looking! :-)
|>
|> Does anyone have any idea what the SoNode::copy() method does such
|> that it cannot copy nodes with a refcount of 0 without destroying
|> them?  

There's lots of bookkeeping going on during a copy so that instances
will not be copied twice.

----


 
 
 

1. ref count probs with SoTransformManip::replaceNode()

Hi!

I've recently mentioned a problem with the reference counters, when
debugging a program, that employs manipulators.

Here is a short test program, that demonstrates the problem, if it is
debugged line by line with e.g. cvd:

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

#include <Inventor/Xt/SoXt.h>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/manips/SoTransformerManip.h>
#include <Inventor/SoPath.h>
#include <Inventor/nodes/SoSeparator.h>

main(int argc, char **argv)
{
    // Initialize Inventor
    SoXt::init("testManip");

    // create simple scene:
    SoSeparator *sep = new SoSeparator;
    sep->ref();
    SoTransform *xform = new SoTransform;
    sep->addChild(xform);
    SoCone *cone = new SoCone; sep->addChild(cone);

    SoPath *xfPath = new SoPath(sep);   // sep->refCount is 2 -> OK.
    xfPath->ref();
    xfPath->append(xform);           // xform->refCount is 2 -> OK.

    SoTransformerManip *xfManip = new SoTransformerManip();

    xfManip->replaceNode(xfPath);    
    // This is, where the problem occurs:
    // sep->refCount is 3 (why isn't it 2 ?)
    // xfManip->refCount is 3 (why isn't it 2 ?)
    // (xform->refCount is 0 and thus destroyed -> OK)

    xfPath->unref();
    // sep->refCount is 2 (should be 1 !)
    // xfManip->refCount is 2 (should be 1 !)

    return 0;

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

The problem gets even worse, if there is no other node than the xform
under the separator (i.e. no cone in the example) - try it.

Did I make any mistakes or is this an Inventor bug ?

I use OpenInventor 2.1. By the way:
What's the difference between Open Inventor 2.1 and OI 2.1.1 ?
Is there already a list of known bugs of OI 2.1 / 2.1.1 ?

P.S.: I mentioned the error, as my deleteCallback for the root separator
      didn't trigger, when I removed it from its parent.

--

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// GMD - German National Research Center for Information Technology, H & S
// Schloss Birlinghoven | D-53757 St. Augustin | Phone: [49-2241-]14-2363

2. HELP NEEDED: converting .tif to .bmp or .dxf

3. SoXtClipBoard and SoNode::copy() Iv2.0 question

4. SIGGRAPH proceedings

5. Disabling SoNode::copy() or SoType::createInstance()

6. HELP!! I am searching for a tree in 3D (DXF, DWG, 3DS, MAX)!!

7. SoNode copy() method

8. A quick raytrace.

9. ref:I am doing a reseach on animation!!!

10. box counting method required

11. why slow in REF mode ?

12. It's done, done, done!