[pkg-fgfs-crew] [simgear] 01/03: Import simgear version 2.12.1
Markus Wanner
markus_wanner-guest at moszumanska.debian.org
Tue Jan 21 21:25:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
markus_wanner-guest pushed a commit to branch master
in repository simgear.
commit 290dc05c31b13c0062830375a0a1d42f3ded15a3
Author: Markus Wanner <markus at bluegap.ch>
Date: Tue Jan 21 21:09:57 2014 +0100
Import simgear version 2.12.1
---
simgear/io/sg_binobj.cxx | 41 ++++++++++++------------
simgear/misc/sg_dir.cxx | 6 +++-
simgear/nasal/code.c | 6 ++--
simgear/nasal/codegen.c | 15 ++++++++-
simgear/nasal/cppbind/Ghost.hxx | 23 ++++++++++---
simgear/nasal/cppbind/detail/to_nasal_helper.cxx | 16 ++++++++-
simgear/props/props.hxx | 7 ++++
simgear/scene/tgdb/SGReaderWriterBTG.cxx | 16 ++++++---
version | 2 +-
9 files changed, 97 insertions(+), 35 deletions(-)
diff --git a/simgear/io/sg_binobj.cxx b/simgear/io/sg_binobj.cxx
index 994f3db..7cb0574 100644
--- a/simgear/io/sg_binobj.cxx
+++ b/simgear/io/sg_binobj.cxx
@@ -43,6 +43,7 @@
#include <simgear/bucket/newbucket.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/math/SGGeometry.hxx>
+#include <simgear/structure/exception.hxx>
#include "lowlevel.hxx"
#include "sg_binobj.hxx"
@@ -319,15 +320,18 @@ void SGBinObject::read_object( gzFile fp,
}
if ( sgReadError() ) {
- cout << "We detected an error reading object properties" << endl;
- return;
+ throw sg_exception("Error reading object properties");
+ }
+
+ size_t indexCount = std::bitset<32>(idx_mask).count();
+ if (indexCount == 0) {
+ throw sg_exception("object index mask has no bits set");
}
for ( j = 0; j < nelements; ++j ) {
sgReadUInt( fp, &nbytes );
if ( sgReadError() ) {
- cout << "We detected an error reading element size for :" << j << endl;
- return;
+ throw sg_exception("Error reading element size");
}
buf.resize( nbytes );
@@ -335,8 +339,7 @@ void SGBinObject::read_object( gzFile fp,
sgReadBytes( fp, nbytes, ptr );
if ( sgReadError() ) {
- cout << "We detected an error reading object element:" << j << "bytes="<< nbytes << endl;
- return;
+ throw sg_exception("Error reading element bytes");
}
int_list vs;
@@ -405,7 +408,7 @@ bool SGBinObject::read_bin( const string& file ) {
SG_LOG( SG_EVENT, SG_ALERT,
"ERROR: opening " << file << " or " << filegz << " for reading!");
- return false;
+ throw sg_io_exception("Error opening for reading (and .gz)", sg_location(file));
}
}
@@ -423,9 +426,7 @@ bool SGBinObject::read_bin( const string& file ) {
} else {
// close the file before we return
gzclose(fp);
- SG_LOG( SG_EVENT, SG_ALERT,
- "ERROR: " << file << "has bad header");
- return false;
+ throw sg_io_exception("Bad BTG magic/version", sg_location(file));
}
// read creation time
@@ -462,8 +463,7 @@ bool SGBinObject::read_bin( const string& file ) {
//cout << "Total objects to read = " << nobjects << endl;
if ( sgReadError() ) {
- cout << "Error while reading header of file " << file << "(.gz)" << endl;
- return false;
+ throw sg_io_exception("Error reading BTG file header", sg_location(file));
}
// read in objects
@@ -613,19 +613,13 @@ bool SGBinObject::read_bin( const string& file ) {
}
if ( sgReadError() ) {
- cout << "Error while reading object:" << i << " in file " << file << "(.gz)" << endl;
- return false;
+ throw sg_io_exception("Error while reading object", sg_location(file, i));
}
}
// close the file
gzclose(fp);
- if ( sgReadError() ) {
- cout << "Error while reading file " << file << "(.gz)" << endl;
- return false;
- }
-
return true;
}
@@ -665,7 +659,7 @@ void SGBinObject::write_objects(gzFile fp, int type, const group_list& verts,
if (verts.empty()) {
return;
}
-
+
unsigned int start = 0, end = 1;
string m;
int_list emptyList;
@@ -688,6 +682,13 @@ void SGBinObject::write_objects(gzFile fp, int type, const group_list& verts,
if ( !normals.empty() && !normals.front().empty()) idx_mask |= SG_IDX_NORMALS;
if ( !colors.empty() && !colors.front().empty()) idx_mask |= SG_IDX_COLORS;
if ( !texCoords.empty() && !texCoords.front().empty()) idx_mask |= SG_IDX_TEXCOORDS;
+
+ if (idx_mask == 0) {
+ SG_LOG(SG_IO, SG_ALERT, "SGBinObject::write_objects: object with material:"
+ << m << "has no indices set");
+ }
+
+
sgWriteChar( fp, (char)SG_INDEX_TYPES ); // property
sgWriteUInt( fp, 1 ); // nbytes
sgWriteChar( fp, idx_mask );
diff --git a/simgear/misc/sg_dir.cxx b/simgear/misc/sg_dir.cxx
index 9a084a6..5ffc10d 100644
--- a/simgear/misc/sg_dir.cxx
+++ b/simgear/misc/sg_dir.cxx
@@ -149,7 +149,11 @@ PathList Dir::children(int types, const std::string& nameFilter) const
WIN32_FIND_DATA fData;
HANDLE find = FindFirstFile(search.c_str(), &fData);
if (find == INVALID_HANDLE_VALUE) {
- SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: FindFirstFile failed:" << _path.str());
+ int err = GetLastError();
+ if (err != ERROR_FILE_NOT_FOUND) {
+ SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: FindFirstFile failed:" <<
+ _path.str() << " with error:" << err);
+ }
return result;
}
diff --git a/simgear/nasal/code.c b/simgear/nasal/code.c
index 5601b07..97c061f 100644
--- a/simgear/nasal/code.c
+++ b/simgear/nasal/code.c
@@ -851,8 +851,10 @@ naRef naCall(naContext ctx, naRef func, int argc, naRef* args,
}
if(IS_CCODE(PTR(func).func->code)) {
- naCFunction fp = PTR(PTR(func).func->code).ccode->fptr;
- result = (*fp)(ctx, obj, argc, args);
+ struct naCCode *ccode = PTR(PTR(func).func->code).ccode;
+ result = ccode->fptru
+ ? (*ccode->fptru)(ctx, obj, argc, args, ccode->user_data)
+ : (*ccode->fptr) (ctx, obj, argc, args);
if(!ctx->callParent) naModUnlock();
return result;
}
diff --git a/simgear/nasal/codegen.c b/simgear/nasal/codegen.c
index 059c114..0045a89 100644
--- a/simgear/nasal/codegen.c
+++ b/simgear/nasal/codegen.c
@@ -147,7 +147,15 @@ static void genEqOp(int op, struct Parser* p, struct Token* t)
static int defArg(struct Parser* p, struct Token* t)
{
- if(t->type == TOK_LPAR) return defArg(p, RIGHT(t));
+ if(t->type == TOK_LPAR) {
+ // http://code.google.com/p/flightgear-bugs/issues/detail?id=737
+ // TOK_LPAR can mean multi-value assignment or function call,
+ // disambigaute by checking the rule of the token
+ if (t->rule == PREC_SUFFIX)
+ naParseError(p, "default arguments cannot be function calls", t->line);
+ return defArg(p, RIGHT(t));
+ }
+
if(t->type == TOK_MINUS && RIGHT(t) &&
RIGHT(t)->type == TOK_LITERAL && !RIGHT(t)->str)
{
@@ -477,6 +485,11 @@ static int tokMatch(struct Token* a, struct Token* b)
static void genBreakContinue(struct Parser* p, struct Token* t)
{
int levels = 1, loop = -1, bp, cp, i;
+ // http://code.google.com/p/flightgear-bugs/issues/detail?id=587
+ // Make sure we are inside of a loop
+ if(p->cg->loopTop <= 0)
+ naParseError(p, "break/continue outside of a valid loop", t->line);
+
if(RIGHT(t)) {
if(RIGHT(t)->type != TOK_SYMBOL)
naParseError(p, "bad break/continue label", t->line);
diff --git a/simgear/nasal/cppbind/Ghost.hxx b/simgear/nasal/cppbind/Ghost.hxx
index 2732c3a..ac84496 100644
--- a/simgear/nasal/cppbind/Ghost.hxx
+++ b/simgear/nasal/cppbind/Ghost.hxx
@@ -233,11 +233,24 @@ namespace nasal
if( !holder )
naRuntimeError(c, "invalid method holder!");
- return holder->_method
- (
- requireObject(c, me),
- CallContext(c, argc, args)
- );
+ try
+ {
+ return holder->_method
+ (
+ requireObject(c, me),
+ CallContext(c, argc, args)
+ );
+ }
+ catch(const std::exception& ex)
+ {
+ naRuntimeError(c, "Fatal error in method call: %s", ex.what());
+ }
+ catch(...)
+ {
+ naRuntimeError(c, "Unknown exception in method call.");
+ }
+
+ return naNil();
}
};
diff --git a/simgear/nasal/cppbind/detail/to_nasal_helper.cxx b/simgear/nasal/cppbind/detail/to_nasal_helper.cxx
index 8e6e22b..5c877e4 100644
--- a/simgear/nasal/cppbind/detail/to_nasal_helper.cxx
+++ b/simgear/nasal/cppbind/detail/to_nasal_helper.cxx
@@ -84,7 +84,21 @@ namespace nasal
{
free_function_t* func = static_cast<free_function_t*>(user_data);
assert(func);
- return (*func)(nasal::CallContext(c, argc, args));
+
+ try
+ {
+ return (*func)(nasal::CallContext(c, argc, args));
+ }
+ catch(const std::exception& ex)
+ {
+ naRuntimeError(c, "Fatal error in Nasal call: %s", ex.what());
+ }
+ catch(...)
+ {
+ naRuntimeError(c, "Unknown exception in Nasal call.");
+ }
+
+ return naNil();
}
//----------------------------------------------------------------------------
diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx
index 5103e8c..0ea51fc 100644
--- a/simgear/props/props.hxx
+++ b/simgear/props/props.hxx
@@ -2039,6 +2039,13 @@ public:
{
_property->addChangeListener(this,initial);
}
+
+ SGPropertyChangeCallback(const SGPropertyChangeCallback<T>& other) :
+ _obj(other._obj), _callback(other._callback), _property(other._property)
+ {
+ _property->addChangeListener(this,false);
+ }
+
virtual ~SGPropertyChangeCallback()
{
_property->removeChangeListener(this);
diff --git a/simgear/scene/tgdb/SGReaderWriterBTG.cxx b/simgear/scene/tgdb/SGReaderWriterBTG.cxx
index ba53ee3..fa0a217 100644
--- a/simgear/scene/tgdb/SGReaderWriterBTG.cxx
+++ b/simgear/scene/tgdb/SGReaderWriterBTG.cxx
@@ -24,6 +24,7 @@
#include <simgear/scene/model/ModelRegistry.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
+#include <simgear/structure/exception.hxx>
#include "SGReaderWriterBTG.hxx"
#include "obj.hxx"
@@ -60,10 +61,17 @@ SGReaderWriterBTG::readNode(const std::string& fileName,
{
const SGReaderWriterOptions* sgOptions;
sgOptions = dynamic_cast<const SGReaderWriterOptions*>(options);
- osg::Node* result = SGLoadBTG(fileName, sgOptions);
- if (!result)
- return ReadResult::FILE_NOT_HANDLED;
-
+ osg::Node* result = NULL;
+ try {
+ result = SGLoadBTG(fileName, sgOptions);
+ if (!result)
+ return ReadResult::FILE_NOT_HANDLED;
+ } catch (sg_exception& e) {
+ SG_LOG(SG_IO, SG_WARN, "error reading:" << fileName << ":" <<
+ e.getFormattedMessage());
+ return ReadResult::ERROR_IN_READING_FILE;
+ }
+
return result;
}
diff --git a/version b/version
index d8b6989..3cf561c 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-2.12.0
+2.12.1
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/simgear.git
More information about the pkg-fgfs-crew
mailing list