CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/10/10 17:49:46
Modified files: . : ChangeLog server : LoadVariablesThread.cpp LoadVariablesThread.h server/asobj : LoadVars.cpp Log message: * server/LoadVariablesThread.{cpp,h}: throw an exception if stream can't be fetched (NetworkException). * server/asobj/LoadVars.cpp: catch NetworkException while constructing LoadVariablesThread. Fixes assertion failure of bug #19901. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4590&r2=1.4591 http://cvs.savannah.gnu.org/viewcvs/gnash/server/LoadVariablesThread.cpp?cvsroot=gnash&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/gnash/server/LoadVariablesThread.h?cvsroot=gnash&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LoadVars.cpp?cvsroot=gnash&r1=1.30&r2=1.31 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4590 retrieving revision 1.4591 diff -u -b -r1.4590 -r1.4591 --- ChangeLog 10 Oct 2007 14:53:16 -0000 1.4590 +++ ChangeLog 10 Oct 2007 17:49:45 -0000 1.4591 @@ -1,5 +1,13 @@ 2007-10-10 Sandro Santilli <[EMAIL PROTECTED]> + * server/LoadVariablesThread.{cpp,h}: throw an exception + if stream can't be fetched (NetworkException). + * server/asobj/LoadVars.cpp: catch NetworkException while + constructing LoadVariablesThread. Fixes assertion failure + of bug #19901. + +2007-10-10 Sandro Santilli <[EMAIL PROTECTED]> + * server/asobj/xmlsocket.cpp: don't use non-configured as_environment for user-defined event handlers invocation. Index: server/LoadVariablesThread.cpp =================================================================== RCS file: /sources/gnash/gnash/server/LoadVariablesThread.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- server/LoadVariablesThread.cpp 1 Jul 2007 10:54:18 -0000 1.2 +++ server/LoadVariablesThread.cpp 10 Oct 2007 17:49:45 -0000 1.3 @@ -23,6 +23,7 @@ #include "LoadVariablesThread.h" #include "tu_file.h" #include "log.h" +#include "GnashException.h" #include <string> @@ -108,4 +109,26 @@ setCompleted(); } +LoadVariablesThread::LoadVariablesThread(const URL& url, const std::string& postdata) + : + _stream(StreamProvider::getDefaultInstance().getStream(url, postdata)), + _completed(false) +{ + if ( ! _stream.get() ) + { + throw NetworkException(); + } +} + +LoadVariablesThread::LoadVariablesThread(const URL& url) + : + _stream(StreamProvider::getDefaultInstance().getStream(url)), + _completed(false) +{ + if ( ! _stream.get() ) + { + throw NetworkException(); + } +} + } // namespace gnash Index: server/LoadVariablesThread.h =================================================================== RCS file: /sources/gnash/gnash/server/LoadVariablesThread.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- server/LoadVariablesThread.h 1 Jul 2007 10:54:18 -0000 1.2 +++ server/LoadVariablesThread.h 10 Oct 2007 17:49:45 -0000 1.3 @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: LoadVariablesThread.h,v 1.2 2007/07/01 10:54:18 bjacques Exp $ */ +/* $Id: LoadVariablesThread.h,v 1.3 2007/10/10 17:49:45 strk Exp $ */ #ifndef GNASH_LOADVARIABLESTHREAD_H #define GNASH_LOADVARIABLESTHREAD_H @@ -43,6 +43,10 @@ namespace gnash { +// Exception thrown by LoadVariablesThread constructor if unable to connect +// to the stream input. +class NetworkException {}; + /// A manager for loadVariable requests // /// Provides services for starting a "load and parse" thread, checking @@ -54,26 +58,27 @@ typedef std::map<std::string, std::string> ValuesMap; /// Construct a LoadVariablesThread opening a stream for the given URL - LoadVariablesThread(const URL& url) - : - _stream(StreamProvider::getDefaultInstance().getStream(url)), - _completed(false) - { - } + // + /// Throws a NetworkException if unable. + /// + /// @param url + /// URL to post to and fetch from + /// + LoadVariablesThread(const URL& url); /// \brief /// Construct a LoadVariablesThread opening a stream for the given URL, /// posting the given url-encoded data if using HTTP. // + /// Throws a NetworkException if unable. + /// + /// @param url + /// URL to post to and fetch from + /// /// @param postdata /// Url-encoded post data. /// - LoadVariablesThread(const URL& url, const std::string& postdata) - : - _stream(StreamProvider::getDefaultInstance().getStream(url, postdata)), - _completed(false) - { - } + LoadVariablesThread(const URL& url, const std::string& postdata); /// Return the name,value map parsed out of the loaded stream ValuesMap& getValues() Index: server/asobj/LoadVars.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/LoadVars.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -b -r1.30 -r1.31 --- server/asobj/LoadVars.cpp 19 Sep 2007 14:20:50 -0000 1.30 +++ server/asobj/LoadVars.cpp 10 Oct 2007 17:49:45 -0000 1.31 @@ -411,10 +411,19 @@ } URL url(urlstr, get_base_url()); - if ( postdata ) { - _loadRequests.insert( _loadRequests.end(), new LoadVariablesThread(url, postdata) ); - } else { - _loadRequests.insert( _loadRequests.end(), new LoadVariablesThread(url) ); + + std::auto_ptr<LoadVariablesThread> newThread; + + try + { + if ( postdata ) newThread.reset( new LoadVariablesThread(url, postdata) ); + else newThread.reset( new LoadVariablesThread(url) ); + + _loadRequests.insert( _loadRequests.end(), newThread.release() ); + } + catch (NetworkException&) + { + log_error(_("Could not load variables from %s"), url.str().c_str()); } } _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit