VrmlNodeType* VrmlScene::readPROTO( VrmlMFString *urls, Doc *relative ) { // This is a problem. The nodeType of the EXTERNPROTO has a namespace // that refers back to this namespace (protos), which will be invalid // after we exit this function. I guess it needs to be allocated and // ref counted too... VrmlNamespace protos; Doc urlDoc; VrmlNodeType* def = 0; int i, n = urls->size(); theSystem->debug("readPROTO\n"); for (i=0; i<n; ++i) { //theSystem->debug("Trying to read url '%s'\n", urls->get(i)); urlDoc.seturl( urls->get(i), relative ); VrmlMFNode *kids = VrmlScene::readWrl( &urlDoc, &protos ); if ( kids ) delete kids; // Grab the specified PROTO, or the first one. const char *whichProto = urlDoc.urlModifier(); if (*whichProto) def = (VrmlNodeType*) protos.findType( whichProto+1 ); else def = (VrmlNodeType*) protos.firstType(); if (def) { def->setActualUrl( urlDoc.url() ); break; } else if (i < n-1 && strncmp(urls->get(i),"urn:",4)) theSystem->warn("Couldn't read EXTERNPROTO url '%s': %s\n", urls->get(i), strerror( errno)); } return def; }