From: Braden M. <br...@us...> - 2006-07-09 05:25:05
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23167/src/libopenvrml/openvrml Modified Files: vrml97node.cpp Log Message: Swallow the openvrml::no_alternative_url exception when loading Background node textures. Index: vrml97node.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/vrml97node.cpp,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** vrml97node.cpp 7 Jun 2006 14:36:45 -0000 1.106 --- vrml97node.cpp 9 Jul 2006 05:25:00 -0000 1.107 *************** *** 2602,2606 **** virtual void do_shutdown(double timestamp) OPENVRML_NOTHROW; ! void update_textures(); }; --- 2602,2606 ---- virtual void do_shutdown(double timestamp) OPENVRML_NOTHROW; ! void update_textures() OPENVRML_THROW1(std::bad_alloc); }; *************** *** 7182,7186 **** assert(err->stream_listener); std::ostringstream msg; ! msg << err->stream_listener->uri_ << ": " << buffer << std::endl; openvrml::browser & browser = err->stream_listener->node_.type().metatype().browser(); --- 7182,7186 ---- assert(err->stream_listener); std::ostringstream msg; ! msg << err->stream_listener->uri_ << ": " << buffer; openvrml::browser & browser = err->stream_listener->node_.type().metatype().browser(); *************** *** 7446,7554 **** } /** * @brief Called lazily to update texture data. */ void background_node::update_textures() { if (this->front_needs_update) { ! if (this->front_url_.mfstring::value().empty()) { ! this->front = image(); ! } else { ! using std::auto_ptr; ! auto_ptr<resource_istream> in( ! this->scene()->get_resource( ! this->front_url_.mfstring::value())); ! auto_ptr<stream_listener> listener( ! new image_stream_listener(in->url(), ! this->front, ! *this, ! this->mutex())); ! read_stream(in, listener); ! } this->front_needs_update = false; } if (this->back_needs_update) { ! if (this->back_url_.mfstring::value().empty()) { ! this->back = image(); ! } else { ! using std::auto_ptr; ! auto_ptr<resource_istream> in( ! this->scene()->get_resource( ! this->back_url_.mfstring::value())); ! auto_ptr<stream_listener> listener( ! new image_stream_listener(in->url(), ! this->back, ! *this, ! this->mutex())); ! read_stream(in, listener); ! } this->back_needs_update = false; } if (this->left_needs_update) { ! if (this->left_url_.mfstring::value().empty()) { ! this->left = image(); ! } else { ! using std::auto_ptr; ! auto_ptr<resource_istream> in( ! this->scene()->get_resource( ! this->left_url_.mfstring::value())); ! auto_ptr<stream_listener> listener( ! new image_stream_listener(in->url(), ! this->left, ! *this, ! this->mutex())); ! read_stream(in, listener); ! } this->left_needs_update = false; } if (this->right_needs_update) { ! if (this->right_url_.mfstring::value().empty()) { ! this->right = image(); ! } else { ! using std::auto_ptr; ! auto_ptr<resource_istream> in( ! this->scene()->get_resource( ! this->right_url_.mfstring::value())); ! auto_ptr<stream_listener> listener( ! new image_stream_listener(in->url(), ! this->right, ! *this, ! this->mutex())); ! read_stream(in, listener); ! } this->right_needs_update = false; } if (this->top_needs_update) { ! if (this->top_url_.mfstring::value().empty()) { ! this->top = image(); ! } else { ! using std::auto_ptr; ! auto_ptr<resource_istream> in( ! this->scene()->get_resource( ! this->top_url_.mfstring::value())); ! auto_ptr<stream_listener> listener( ! new image_stream_listener(in->url(), ! this->top, ! *this, ! this->mutex())); ! read_stream(in, listener); ! } this->top_needs_update = false; } if (this->bottom_needs_update) { ! if (this->bottom_url_.mfstring::value().empty()) { ! this->bottom = image(); ! } else { ! using std::auto_ptr; ! auto_ptr<resource_istream> in( ! this->scene()->get_resource( ! this->bottom_url_.mfstring::value())); ! auto_ptr<stream_listener> listener( ! new image_stream_listener(in->url(), ! this->bottom, ! *this, ! this->mutex())); ! read_stream(in, listener); ! } this->bottom_needs_update = false; } --- 7446,7520 ---- } + void update_texture(background_node & node, + boost::recursive_mutex & node_mutex, + const openvrml::mfstring & url, + openvrml::image & img) + OPENVRML_THROW1(std::bad_alloc) + try { + using openvrml::image; + + if (url.value().empty()) { + img = image(); + } else { + using std::auto_ptr; + using openvrml::resource_istream; + + auto_ptr<resource_istream> in( + node.scene()->get_resource(url.value())); + auto_ptr<stream_listener> listener( + new image_stream_listener(in->url(), + img, + node, + node_mutex)); + read_stream(in, listener); + } + } catch (const openvrml::no_alternative_url & ex) {} + /** * @brief Called lazily to update texture data. */ void background_node::update_textures() + OPENVRML_THROW1(std::bad_alloc) { if (this->front_needs_update) { ! update_texture(*this, ! this->mutex(), ! this->front_url_, ! this->front); this->front_needs_update = false; } if (this->back_needs_update) { ! update_texture(*this, ! this->mutex(), ! this->back_url_, ! this->back); this->back_needs_update = false; } if (this->left_needs_update) { ! update_texture(*this, ! this->mutex(), ! this->left_url_, ! this->left); this->left_needs_update = false; } if (this->right_needs_update) { ! update_texture(*this, ! this->mutex(), ! this->right_url_, ! this->right); this->right_needs_update = false; } if (this->top_needs_update) { ! update_texture(*this, ! this->mutex(), ! this->top_url_, ! this->top); this->top_needs_update = false; } if (this->bottom_needs_update) { ! update_texture(*this, ! this->mutex(), ! this->bottom_url_, ! this->bottom); this->bottom_needs_update = false; } |