From 840780dc4acf8afd08f648b1e3d83c2294bb081b Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Thu, 20 Jan 2011 01:06:46 +0100 Subject: [PATCH 1/5] Another place to catch SG exceptions. SGBinding::fire needs to catch, otherwise exceptions in the event handler context cause an FG exit (fixes a crash with the route manager dialog). --- simgear/structure/SGBinding.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/simgear/structure/SGBinding.cxx b/simgear/structure/SGBinding.cxx index 9e5fce06..836d7abc 100644 --- a/simgear/structure/SGBinding.cxx +++ b/simgear/structure/SGBinding.cxx @@ -16,6 +16,8 @@ #include +#include + SGBinding::SGBinding() : _command(0), _arg(new SGPropertyNode), @@ -62,9 +64,17 @@ SGBinding::fire () const _command = SGCommandMgr::instance()->getCommand(_command_name); if (_command == 0) { SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding"); - } else if (!(*_command)(_arg)) { - SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command " - << _command_name); + } else + { + try { + if (!(*_command)(_arg)) { + SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command " + << _command_name); + } + } catch (sg_exception& e) { + SG_LOG(SG_GENERAL, SG_ALERT, "command '" << _command_name << "' failed with exception\n" + << "\tmessage:" << e.getMessage() << " (from " << e.getOrigin() << ")"); + } } } } From 6d2646239e70d46e993d08492da43c4583c4e519 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Tue, 25 Jan 2011 22:58:50 +0100 Subject: [PATCH 2/5] Fix wrong difference calculation in SGExpression --- simgear/structure/SGExpression.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simgear/structure/SGExpression.hxx b/simgear/structure/SGExpression.hxx index 6f90061c..ffb9dd1d 100644 --- a/simgear/structure/SGExpression.hxx +++ b/simgear/structure/SGExpression.hxx @@ -807,9 +807,9 @@ public: { } virtual void eval(T& value, const simgear::expression::Binding* b) const { - value = T(0); + value = getOperand(0)->getValue(b); unsigned sz = SGNaryExpression::getNumOperands(); - for (unsigned i = 0; i < sz; ++i) + for (unsigned i = 1; i < sz; ++i) value -= getOperand(i)->getValue(b); } using SGNaryExpression::getValue; From 73084863b744534853e59fa7fe3e0547fc15ee4a Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 6 Feb 2011 10:04:55 +0100 Subject: [PATCH 3/5] Temporary warning when compiling against OSG 2.9.11. Current OSG development isn't supported by FG yet, so add a warning for now... --- simgear/scene/model/SGPagedLOD.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/simgear/scene/model/SGPagedLOD.cxx b/simgear/scene/model/SGPagedLOD.cxx index 0b837b36..02b187ea 100644 --- a/simgear/scene/model/SGPagedLOD.cxx +++ b/simgear/scene/model/SGPagedLOD.cxx @@ -68,9 +68,30 @@ void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp, osg::FrameStamp* framestam unsigned childNum = getNumChildren(); setTimeStamp(childNum, 0); double priority=1.0; +#if SG_OSG_MIN_VERSION_REQUIRED(2,9,11) + // osgDB::DatabasePager::requestNodeFile changed with OSG 2.9.11 + + #ifdef __GNUC__ + #warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + #warning !! Your version of OpenSceneGraph is currently unsupported. + #warning !! Use latest stable OSG (2.8.3) or a OSG developer release up to 2.9.10. + #warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + #else + // Alas! Why is MSVC different (again)? :) + #pragma WARNING( Your version of OpenSceneGraph is currently unsupported. ) + #pragma WARNING( Use latest stable OSG (2.8.3) or a OSG developer release up to 2.9.10. ) + #endif + + //TODO We need to adapt to OSG 2.9.11 (and future releases). This doesn't work yet... dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp, getDatabaseRequest(childNum), _readerWriterOptions.get()); +#else + // OSG revisions up to 2.9.10 + dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp, + getDatabaseRequest(childNum), + _readerWriterOptions.get()); +#endif } bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw) From 5208750cdb34ed98411a2104963965b08fb72a47 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Fri, 11 Feb 2011 18:49:01 +0100 Subject: [PATCH 4/5] Ivan Ngeow: Fixed compile for FreeBSD platforms. --- simgear/io/raw_socket.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simgear/io/raw_socket.hxx b/simgear/io/raw_socket.hxx index f68ff105..4eb30448 100644 --- a/simgear/io/raw_socket.hxx +++ b/simgear/io/raw_socket.hxx @@ -25,7 +25,7 @@ #include -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(__FreeBSD__) # include #endif @@ -38,7 +38,7 @@ namespace simgear class IPAddress { /* DANGER!!! This MUST match 'struct sockaddr_in' exactly! */ -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) __uint8_t sin_len; __uint8_t sin_family; in_port_t sin_port; From df6badfdd5fb1a07679c738376dfe86005694624 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 15 Feb 2011 12:28:03 +0100 Subject: [PATCH 5/5] accomodate changes to osgDB::DatabasePager interface The change was introduced in OSG SVN revision 12080. Note: that revision has a bug that causes fgfs to crash. The bug is fixed in revision 12170. --- simgear/scene/model/CheckSceneryVisitor.cxx | 2 +- simgear/scene/model/SGPagedLOD.cxx | 39 ++++++++----------- simgear/scene/model/SGPagedLOD.hxx | 24 +++++++++--- .../scene/tgdb/SGReaderWriterBTGOptions.hxx | 1 + 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/simgear/scene/model/CheckSceneryVisitor.cxx b/simgear/scene/model/CheckSceneryVisitor.cxx index a21f103b..4a0625bc 100644 --- a/simgear/scene/model/CheckSceneryVisitor.cxx +++ b/simgear/scene/model/CheckSceneryVisitor.cxx @@ -54,7 +54,7 @@ void CheckSceneryVisitor::apply(osg::PagedLOD& node) // if the DatabasePager would load LODs while the splashscreen // is there, we could just wait for the models to be loaded // by only setting setLoaded(false) here - sgplod->forceLoad(_dbp,_framestamp); + sgplod->forceLoad(_dbp,_framestamp, getNodePath()); setLoaded(false); } } diff --git a/simgear/scene/model/SGPagedLOD.cxx b/simgear/scene/model/SGPagedLOD.cxx index 02b187ea..531b45b0 100644 --- a/simgear/scene/model/SGPagedLOD.cxx +++ b/simgear/scene/model/SGPagedLOD.cxx @@ -61,37 +61,30 @@ bool SGPagedLOD::addChild(osg::Node *child) return true; } -void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp, osg::FrameStamp* framestamp) +// Work around interface change in osgDB::DatabasePager::requestNodeFile +struct NodePathProxy +{ + NodePathProxy(NodePath& nodePath) + : _nodePath(nodePath) + { + } + operator Group* () { return static_cast(_nodePath.back()); } + operator NodePath& () { return _nodePath; } + NodePath& _nodePath; +}; + +void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp, FrameStamp* framestamp, + NodePath& path) { //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" << //getFileName(getNumChildren()) << ")"); unsigned childNum = getNumChildren(); setTimeStamp(childNum, 0); double priority=1.0; -#if SG_OSG_MIN_VERSION_REQUIRED(2,9,11) - // osgDB::DatabasePager::requestNodeFile changed with OSG 2.9.11 - - #ifdef __GNUC__ - #warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - #warning !! Your version of OpenSceneGraph is currently unsupported. - #warning !! Use latest stable OSG (2.8.3) or a OSG developer release up to 2.9.10. - #warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - #else - // Alas! Why is MSVC different (again)? :) - #pragma WARNING( Your version of OpenSceneGraph is currently unsupported. ) - #pragma WARNING( Use latest stable OSG (2.8.3) or a OSG developer release up to 2.9.10. ) - #endif - - //TODO We need to adapt to OSG 2.9.11 (and future releases). This doesn't work yet... - dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp, + dbp->requestNodeFile(getFileName(childNum), NodePathProxy(path), + priority, framestamp, getDatabaseRequest(childNum), _readerWriterOptions.get()); -#else - // OSG revisions up to 2.9.10 - dbp->requestNodeFile(getFileName(childNum),this,priority,framestamp, - getDatabaseRequest(childNum), - _readerWriterOptions.get()); -#endif } bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw) diff --git a/simgear/scene/model/SGPagedLOD.hxx b/simgear/scene/model/SGPagedLOD.hxx index fe256446..a9e55d96 100644 --- a/simgear/scene/model/SGPagedLOD.hxx +++ b/simgear/scene/model/SGPagedLOD.hxx @@ -18,10 +18,13 @@ #define SGPAGEDLOD_HXX 1 #include + +#define SG_PAGEDLOD_HAS_OPTIONS \ + (SG_OSG_VERSION >= 29005 \ + || (SG_OSG_VERSION < 29000 && SG_OSG_VERSION >= 28003)) + #include -#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5) -#include -#endif +#include #include #include @@ -43,26 +46,35 @@ public: META_Node(simgear, SGPagedLOD); // virtual void traverse(osg::NodeVisitor& nv); - virtual void forceLoad(osgDB::DatabasePager* dbp, osg::FrameStamp* framestamp); + virtual void forceLoad(osgDB::DatabasePager* dbp, + osg::FrameStamp* framestamp, + osg::NodePath& path); // reimplemented to notify the loading through ModelData bool addChild(osg::Node *child); void setReaderWriterOptions(osgDB::ReaderWriter::Options *options) { - _readerWriterOptions = options; options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE); -#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5) +#if SG_PAGEDLOD_HAS_OPTIONS setDatabaseOptions(options); +#else + _readerWriterOptions = options; #endif } osgDB::ReaderWriter::Options* getReaderWriterOptions() { +#if SG_PAGEDLOD_HAS_OPTIONS + return static_cast(getDatabaseOptions()); +#else return _readerWriterOptions.get(); +#endif } protected: virtual ~SGPagedLOD(); +#if SG_PAGEDLOD_HAS_OPTIONS osg::ref_ptr _readerWriterOptions; +#endif }; } #endif diff --git a/simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx b/simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx index b1d21b5d..097d3fcd 100644 --- a/simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx +++ b/simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx @@ -21,6 +21,7 @@ #include class SGReaderWriterBTGOptions : public osgDB::ReaderWriter::Options { public: + META_Object(simgear,SGReaderWriterBTGOptions); SGReaderWriterBTGOptions(const std::string& str = std::string()) : osgDB::ReaderWriter::Options(str), _matlib(0), _calcLights(true),