diff --git a/src/osgPlugins/3ds/readwrite.cpp b/src/osgPlugins/3ds/readwrite.cpp index cf03edbd5..e2b236522 100644 --- a/src/osgPlugins/3ds/readwrite.cpp +++ b/src/osgPlugins/3ds/readwrite.cpp @@ -54,7 +54,8 @@ lib3ds_byte_read(FILE *f) Lib3dsByte b; ASSERT(f); - fread(&b,1,1,f); + int result = fread(&b,1,1,f); + if (result==0) return 0; return(b); } @@ -73,7 +74,9 @@ lib3ds_word_read(FILE *f) Lib3dsWord w; ASSERT(f); - fread(b,2,1,f); + int result = fread(b,2,1,f); + if (result==0) return 0; + w=((Lib3dsWord)b[1] << 8) | ((Lib3dsWord)b[0]); return(w); @@ -96,7 +99,9 @@ lib3ds_dword_read(FILE *f) Lib3dsDword d; ASSERT(f); - fread(b,4,1,f); + int result = fread(b,4,1,f); + if (result==0) return 0; + d=((Lib3dsDword)b[3] << 24) | ((Lib3dsDword)b[2] << 16) | ((Lib3dsDword)b[1] << 8) | @@ -120,7 +125,9 @@ lib3ds_intb_read(FILE *f) Lib3dsIntb b; ASSERT(f); - fread(&b,1,1,f); + int result = fread(&b,1,1,f); + if (result==0) return 0; + return(b); } @@ -140,7 +147,8 @@ lib3ds_intw_read(FILE *f) Lib3dsByte b[2]; ASSERT(f); - fread(b,2,1,f); + int result = fread(b,2,1,f); + if (result==0) return 0; if (s_requiresByteSwap) { @@ -166,7 +174,8 @@ lib3ds_intd_read(FILE *f) Lib3dsByte b[4]; ASSERT(f); - fread(b,4,1,f); + int result = fread(b,4,1,f); + if (result==0) return 0; if (s_requiresByteSwap) { @@ -192,7 +201,8 @@ lib3ds_float_read(FILE *f) Lib3dsByte b[4]; ASSERT(f); - fread(b,4,1,f); + int result = fread(b,4,1,f); + if (result==0) return 0; if (s_requiresByteSwap) { @@ -434,18 +444,30 @@ lib3ds_intd_write(Lib3dsIntd d, FILE *f) * * \return True on success, False otherwise. */ + + Lib3dsBool lib3ds_float_write(Lib3dsFloat l, FILE *f) { - Lib3dsByte b[4]; - Lib3dsDword d; - ASSERT(f); - d=*((Lib3dsDword*)&l); - b[3]=(Lib3dsByte)(((Lib3dsDword)d & 0xFF000000) >> 24); - b[2]=(Lib3dsByte)(((Lib3dsDword)d & 0x00FF0000) >> 16); - b[1]=(Lib3dsByte)(((Lib3dsDword)d & 0x0000FF00) >> 8); - b[0]=(Lib3dsByte)(((Lib3dsDword)d & 0x000000FF)); + Lib3dsByte b[4]; + Lib3dsByte* ptr = (Lib3dsByte*) (&l); + + if (s_requiresByteSwap) + { + b[3] = *ptr++; + b[2] = *ptr++; + b[1] = *ptr++; + b[0] = *ptr++; + } + else + { + b[0] = *ptr++; + b[1] = *ptr++; + b[2] = *ptr++; + b[3] = *ptr++; + } + if (fwrite(b,4,1,f)!=1) { return(LIB3DS_FALSE); } diff --git a/src/osgPlugins/3ds/viewport.cpp b/src/osgPlugins/3ds/viewport.cpp index 3cdc461fd..4dfd87d9d 100644 --- a/src/osgPlugins/3ds/viewport.cpp +++ b/src/osgPlugins/3ds/viewport.cpp @@ -83,7 +83,10 @@ lib3ds_viewport_read(Lib3dsViewport *viewport, FILE *f) lib3ds_vector_read(viewport->layout.viewL[cur].center,f); viewport->layout.viewL[cur].horiz_angle=lib3ds_float_read(f); viewport->layout.viewL[cur].vert_angle=lib3ds_float_read(f); - fread(viewport->layout.viewL[cur].camera,11,1,f); + + int result = fread(viewport->layout.viewL[cur].camera,11,1,f); + if (result==0) return (LIB3DS_FALSE); + ++cur; } break; @@ -157,7 +160,8 @@ lib3ds_viewport_read(Lib3dsViewport *viewport, FILE *f) case LIB3DS_VIEW_CAMERA: { viewport->default_view.type=LIB3DS_VIEW_TYPE_CAMERA; - fread(viewport->default_view.camera,11,1,f); + int result = fread(viewport->default_view.camera,11,1,f); + if (result==0) return (LIB3DS_FALSE); } break; default: @@ -249,7 +253,8 @@ lib3ds_viewport_write(Lib3dsViewport *viewport, FILE *f) lib3ds_vector_write(viewport->layout.viewL[i].center,f); lib3ds_float_write(viewport->layout.viewL[i].horiz_angle,f); lib3ds_float_write(viewport->layout.viewL[i].vert_angle,f); - fwrite(viewport->layout.viewL[i].camera,11,1,f); + int result = fwrite(viewport->layout.viewL[i].camera,11,1,f); + if (result==0) return (LIB3DS_FALSE); } if (!lib3ds_chunk_write_end(&c,f)) { @@ -345,7 +350,8 @@ lib3ds_viewport_write(Lib3dsViewport *viewport, FILE *f) c.chunk=LIB3DS_VIEW_CAMERA; c.size=17; lib3ds_chunk_write(&c,f); - fwrite(viewport->default_view.camera,1,11,f); + int result = fwrite(viewport->default_view.camera,1,11,f); + if (result==0) return (LIB3DS_FALSE); } break; } diff --git a/src/osgPlugins/ac/ac3d.cpp b/src/osgPlugins/ac/ac3d.cpp index 2b8c940b3..985db6548 100644 --- a/src/osgPlugins/ac/ac3d.cpp +++ b/src/osgPlugins/ac/ac3d.cpp @@ -1168,7 +1168,8 @@ readObject(std::istream& stream, FileData& fileData, const osg::Matrix& parentTr std::string texname = readString(stream); // strip absolute paths - if (texname[0] == '/' || isalpha(texname[0]) && texname[1] == ':') { + if (texname[0] == '/' || + (isalpha(texname[0]) && texname[1] == ':')) { std::string::size_type p = texname.rfind('\\'); if (p != std::string::npos) texname = texname.substr(p+1, std::string::npos); diff --git a/src/osgPlugins/bsp/VBSPGeometry.cpp b/src/osgPlugins/bsp/VBSPGeometry.cpp index a715dba35..d9647e37d 100644 --- a/src/osgPlugins/bsp/VBSPGeometry.cpp +++ b/src/osgPlugins/bsp/VBSPGeometry.cpp @@ -249,17 +249,17 @@ void VBSPGeometry::createDispSurface(Face & face, DisplaceInfo & dispInfo) Vec3 texV; float texVOffset; float texVScale; - unsigned int i, j, k; + int i, j, k; double dist, minDist; - int minIndex; + int minIndex = 0; osg::Vec3 temp; int edgeIndex; int currentSurfEdge; Edge currentEdge; osg::Vec3 currentVertex; osg::Vec3 vertices[4]; - unsigned int firstVertex; - unsigned int numEdgeVertices; + int firstVertex; + int numEdgeVertices; double subdivideScale; osg::Vec3 leftEdge, rightEdge; osg::Vec3 leftEdgeStep, rightEdgeStep; diff --git a/src/osgPlugins/bsp/VBSPReader.cpp b/src/osgPlugins/bsp/VBSPReader.cpp index c1e4b6c37..c77765238 100644 --- a/src/osgPlugins/bsp/VBSPReader.cpp +++ b/src/osgPlugins/bsp/VBSPReader.cpp @@ -355,11 +355,11 @@ void VBSPReader::processDispVerts(std::istream & str, int offset, int length) std::string VBSPReader::getToken(std::string str, const char * delim, std::string::size_type & index) { - std::string::size_type start, end; std::string token; // Look for the first non-occurrence of the delimiters - start = str.find_first_not_of(" \t\n\r\"", index); + std::string::size_type start = str.find_first_not_of(" \t\n\r\"", index); + std::string::size_type end = std::string::npos; if (start != std::string::npos) { // From there, look for the first occurrence of a delimiter @@ -627,7 +627,6 @@ ref_ptr VBSPReader::readMaterialFile(std::string materialName) bool found = false; ref_ptr stateSet; std::string shaderName; - osg::Image * texImage = 0; std::string texName; std::string tex2Name; ref_ptr texture; diff --git a/src/osgPlugins/curl/ReaderWriterCURL.cpp b/src/osgPlugins/curl/ReaderWriterCURL.cpp index ba10e1688..806c4cac2 100644 --- a/src/osgPlugins/curl/ReaderWriterCURL.cpp +++ b/src/osgPlugins/curl/ReaderWriterCURL.cpp @@ -272,10 +272,12 @@ osgDB::ReaderWriter::ReadResult ReaderWriterCURL::readFile(ObjectType objectType //Setting Proxy by OSG Options if(!optProxy.empty()) + { if(!optProxyPort.empty()) proxyAddress = optProxy + ":" + optProxyPort; else proxyAddress = optProxy + ":8080"; //Port not found, using default + } } std::string fileName; diff --git a/src/osgPlugins/dxf/dxfEntity.h b/src/osgPlugins/dxf/dxfEntity.h index 18d26643b..c59bb1e35 100644 --- a/src/osgPlugins/dxf/dxfEntity.h +++ b/src/osgPlugins/dxf/dxfEntity.h @@ -258,13 +258,13 @@ public: _string(""), _point1(0,0,0), _point2(0,0,0), + _ocs(0,0,1), _height(1), _xscale(1), _rotation(0), _flags(0), _hjustify(0), - _vjustify(0), - _ocs(0,0,1) {} + _vjustify(0) {} virtual ~dxfText() {} virtual dxfBasicEntity* create() { return new dxfText; } diff --git a/src/osgPlugins/logo/ReaderWriterLOGO.cpp b/src/osgPlugins/logo/ReaderWriterLOGO.cpp index 036f2fb2c..f81ffa974 100644 --- a/src/osgPlugins/logo/ReaderWriterLOGO.cpp +++ b/src/osgPlugins/logo/ReaderWriterLOGO.cpp @@ -171,7 +171,7 @@ class Logos: public osg::Drawable bool hasLogos() { int n = 0; - for( int i = Center; i <= last_position; i++ ) + for( int i = Center; i < last_position; i++ ) n += logos[i].size(); return (n != 0); } diff --git a/src/osgPlugins/lwo/lwo2read.h b/src/osgPlugins/lwo/lwo2read.h index 5c4a5bf35..a86c7d5c0 100644 --- a/src/osgPlugins/lwo/lwo2read.h +++ b/src/osgPlugins/lwo/lwo2read.h @@ -67,11 +67,23 @@ U4 read_U4(Iter &it) return u4; } +template +D changeType4(S src) +{ + D dest; + char* dest_ptr = reinterpret_cast(&dest); + char* src_ptr = reinterpret_cast(&src); + for(int i=0; i<4; ++i) + { + *dest_ptr = *src_ptr; + } + return dest; +} + template F4 read_F4(Iter &it) { - U4 u4 = read_U4(it); - return *reinterpret_cast(&u4); + return changeType4(read_U4(it)); } template diff --git a/src/osgPlugins/lwo/old_Lwo2.cpp b/src/osgPlugins/lwo/old_Lwo2.cpp index 04173fc00..af1cfc8af 100644 --- a/src/osgPlugins/lwo/old_Lwo2.cpp +++ b/src/osgPlugins/lwo/old_Lwo2.cpp @@ -41,6 +41,7 @@ #include "old_Lwo2.h" #include "old_Lwo2Layer.h" +#include "lwo2read.h" Lwo2::Lwo2(): _current_layer(0), @@ -77,7 +78,7 @@ Lwo2::ReadFile( const string& filename ) // checking EA-IFF85 format // http://www.lightwave3d.com/developer/75lwsdk/docs/filefmts/eaiff85.html - if (_read_long() != tag_FORM) + if (_read_uint() != tag_FORM) { notify(INFO) << "File '" << filename << "' is not IFF format file." << std::endl; _fin.close(); @@ -88,12 +89,12 @@ Lwo2::ReadFile( const string& filename ) notify(INFO) << "Detected EA-IFF85 format" << std::endl; } - unsigned long form_size = _read_long(); + unsigned int form_size = _read_uint(); notify(INFO) << "Form size: " << form_size << std::endl; // checking LWO2 format // http://www.lightwave3d.com/developer/75lwsdk/docs/filefmts/lwo2.html - if (_read_long() != tag_LWO2) + if (_read_uint() != tag_LWO2) { unsigned long make_id(const char*); notify(INFO) << "File '" << filename << "' is not LWO2 format file." << std::endl; @@ -112,8 +113,8 @@ Lwo2::ReadFile( const string& filename ) // main loop for reading tags while (read_bytes < form_size && !_fin.eof()) { - current_tag_name = _read_long(); - current_tag_size = _read_long(); + current_tag_name = _read_uint(); + current_tag_size = _read_uint(); read_bytes += 8 + current_tag_size + current_tag_size % 2; _print_tag(current_tag_name, current_tag_size); @@ -176,8 +177,8 @@ Lwo2::_read_char() return static_cast(c); } -unsigned long -Lwo2::_read_long() +unsigned int +Lwo2::_read_uint() { return (_read_char() << 24) | @@ -197,8 +198,7 @@ Lwo2::_read_short() float Lwo2::_read_float() { - unsigned long x = _read_long(); - return *(float*)&x; + return lwo2::changeType4(_read_uint()); } // read null terminated string @@ -316,7 +316,7 @@ void Lwo2::_read_points(unsigned long size) void Lwo2::_read_vertex_mapping(unsigned long size) { - unsigned int type = _read_long(); + unsigned int type = _read_uint(); size -= 4; _print_type(type); @@ -364,7 +364,7 @@ void Lwo2::_read_vertex_mapping(unsigned long size) void Lwo2::_read_polygons(unsigned long size) { - unsigned int type = _read_long(); + unsigned int type = _read_uint(); size -= 4; _print_type(type); @@ -408,7 +408,7 @@ Lwo2::_read_polygons(unsigned long size) void Lwo2::_read_polygon_tag_mapping(unsigned long size) { - unsigned int type = _read_long(); + unsigned int type = _read_uint(); size -= 4; _print_type(type); @@ -441,7 +441,7 @@ void Lwo2::_read_polygon_tag_mapping(unsigned long size) void Lwo2::_read_polygons_mapping(unsigned long size) { - unsigned int type = _read_long(); + unsigned int type = _read_uint(); size -= 4; _print_type(type); @@ -503,14 +503,14 @@ void Lwo2::_read_polygons_mapping(unsigned long size) void Lwo2::_read_image_definition(unsigned long size) { - unsigned int index = _read_long(); + unsigned int index = _read_uint(); size -= 4; notify(DEBUG_INFO) << " index \t" << index << std::endl; unsigned int type; while (size > 0) { - type = _read_long(); + type = _read_uint(); size -= 4; _print_type(type); @@ -557,7 +557,7 @@ void Lwo2::_read_surface(unsigned long size) while (size > 0 && !_fin.eof()) { - current_tag_name = _read_long(); + current_tag_name = _read_uint(); size -= 4; current_tag_size = _read_short(); size -= 2; @@ -572,7 +572,7 @@ void Lwo2::_read_surface(unsigned long size) size -= blok_size; while (blok_size > 0) { - current_tag_name = _read_long(); + current_tag_name = _read_uint(); blok_size -= 4; current_tag_size = _read_short(); blok_size -= 2; @@ -599,7 +599,7 @@ void Lwo2::_read_surface(unsigned long size) while(imap_size > 0) { - current_tag_name = _read_long(); + current_tag_name = _read_uint(); imap_size -= 4; current_tag_size = _read_short(); imap_size -= 2; diff --git a/src/osgPlugins/lwo/old_Lwo2.h b/src/osgPlugins/lwo/old_Lwo2.h index abeaddba8..6baf991ac 100644 --- a/src/osgPlugins/lwo/old_Lwo2.h +++ b/src/osgPlugins/lwo/old_Lwo2.h @@ -69,7 +69,7 @@ class Lwo2 unsigned char _read_char(); unsigned short _read_short(); - unsigned long _read_long(); + unsigned int _read_uint(); float _read_float(); string& _read_string(string&); diff --git a/src/osgPlugins/lwo/old_lw.cpp b/src/osgPlugins/lwo/old_lw.cpp index 407c5a648..e65a2c111 100644 --- a/src/osgPlugins/lwo/old_lw.cpp +++ b/src/osgPlugins/lwo/old_lw.cpp @@ -17,6 +17,9 @@ */ #include "old_lw.h" + +#include "lwo2read.h" + #include #include #include @@ -80,10 +83,10 @@ static gint32 read_long(FILE *f) return (read_char(f)<<24) | (read_char(f)<<16) | (read_char(f)<<8) | read_char(f); } + static GLfloat read_float(FILE *f) { - gint32 x = read_long(f); - return *(GLfloat*)&x; + return lwo2::changeType4(read_long(f)); } static gint read_string(FILE *f, char *s) diff --git a/src/osgPlugins/md2/ReaderWriterMD2.cpp b/src/osgPlugins/md2/ReaderWriterMD2.cpp index 4d818116a..7045a6883 100644 --- a/src/osgPlugins/md2/ReaderWriterMD2.cpp +++ b/src/osgPlugins/md2/ReaderWriterMD2.cpp @@ -173,7 +173,11 @@ load_md2 (const char *filename, const osgDB::ReaderWriter::Options* options) } #else mapbase = malloc (st.st_size); - read (file_fd, mapbase, st.st_size); + if (read(file_fd, mapbase, st.st_size)==0) + { + close (file_fd); + return NULL; + } #endif if (g_md2NormalsArray == NULL) { diff --git a/src/osgPlugins/ogr/ReaderWriterOGR.cpp b/src/osgPlugins/ogr/ReaderWriterOGR.cpp index 6821fd4dc..8e9b01a84 100644 --- a/src/osgPlugins/ogr/ReaderWriterOGR.cpp +++ b/src/osgPlugins/ogr/ReaderWriterOGR.cpp @@ -213,7 +213,6 @@ public: { osg::Geometry* geom = new osg::Geometry; - unsigned int total = 0; for (int i = 0; i < mpolygon->getNumGeometries(); i++ ) { OGRGeometry* ogrGeom = mpolygon->getGeometryRef(i); @@ -233,7 +232,6 @@ public: if (!geom->getVertexArray()) { // no yet data we put the first in - osg::Vec3Array* arraySrc = static_cast(geom->getVertexArray()); geom->setVertexArray(geometry->getVertexArray()); geom->setPrimitiveSetList(geometry->getPrimitiveSetList()); diff --git a/src/osgPlugins/osgShadow/ShadowMap.cpp b/src/osgPlugins/osgShadow/ShadowMap.cpp index 246861373..56bca7f83 100644 --- a/src/osgPlugins/osgShadow/ShadowMap.cpp +++ b/src/osgPlugins/osgShadow/ShadowMap.cpp @@ -24,17 +24,17 @@ osgDB::RegisterDotOsgWrapperProxy ShadowMap_Proxy ShadowMap_writeLocalData ); -bool ShadowMap_readLocalData(osg::Object& obj, osgDB::Input &fr) +bool ShadowMap_readLocalData(osg::Object& /*obj*/, osgDB::Input &/*fr*/) { - osgShadow::ShadowMap& ss = static_cast(obj); + // osgShadow::ShadowMap& ss = static_cast(obj); bool itAdvanced = false; return itAdvanced; } -bool ShadowMap_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +bool ShadowMap_writeLocalData(const osg::Object& /*obj*/, osgDB::Output& /*fw*/) { - const osgShadow::ShadowMap& ss = static_cast(obj); + // const osgShadow::ShadowMap& ss = static_cast(obj); return true; } diff --git a/src/osgPlugins/osgShadow/ShadowTechnique.cpp b/src/osgPlugins/osgShadow/ShadowTechnique.cpp index a94530b46..121d7cf2a 100644 --- a/src/osgPlugins/osgShadow/ShadowTechnique.cpp +++ b/src/osgPlugins/osgShadow/ShadowTechnique.cpp @@ -24,17 +24,17 @@ osgDB::RegisterDotOsgWrapperProxy ShadowTechnique_Proxy ShadowTechnique_writeLocalData ); -bool ShadowTechnique_readLocalData(osg::Object& obj, osgDB::Input &fr) +bool ShadowTechnique_readLocalData(osg::Object& /*obj*/, osgDB::Input& /*fr*/) { - osgShadow::ShadowTechnique& ss = static_cast(obj); + //osgShadow::ShadowTechnique& ss = static_cast(obj); bool itAdvanced = false; return itAdvanced; } -bool ShadowTechnique_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +bool ShadowTechnique_writeLocalData(const osg::Object& /*obj*/, osgDB::Output& /*fw*/) { - const osgShadow::ShadowTechnique& ss = static_cast(obj); + //const osgShadow::ShadowTechnique& ss = static_cast(obj); return true; } diff --git a/src/osgPlugins/osgShadow/ShadowTexture.cpp b/src/osgPlugins/osgShadow/ShadowTexture.cpp index d6bc4773c..f00dcda14 100644 --- a/src/osgPlugins/osgShadow/ShadowTexture.cpp +++ b/src/osgPlugins/osgShadow/ShadowTexture.cpp @@ -24,17 +24,17 @@ osgDB::RegisterDotOsgWrapperProxy ShadowTexture_Proxy ShadowTexture_writeLocalData ); -bool ShadowTexture_readLocalData(osg::Object& obj, osgDB::Input &fr) +bool ShadowTexture_readLocalData(osg::Object& /*obj*/, osgDB::Input& /*fr*/) { - osgShadow::ShadowTexture& ss = static_cast(obj); + // osgShadow::ShadowTexture& ss = static_cast(obj); bool itAdvanced = false; return itAdvanced; } -bool ShadowTexture_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +bool ShadowTexture_writeLocalData(const osg::Object& /*obj*/, osgDB::Output& /*fw*/) { - const osgShadow::ShadowTexture& ss = static_cast(obj); + // const osgShadow::ShadowTexture& ss = static_cast(obj); return true; } diff --git a/src/osgPlugins/osgShadow/ShadowVolume.cpp b/src/osgPlugins/osgShadow/ShadowVolume.cpp index f9ff0de1d..33e2c1c8c 100644 --- a/src/osgPlugins/osgShadow/ShadowVolume.cpp +++ b/src/osgPlugins/osgShadow/ShadowVolume.cpp @@ -24,17 +24,17 @@ osgDB::RegisterDotOsgWrapperProxy ShadowVolume_Proxy ShadowVolume_writeLocalData ); -bool ShadowVolume_readLocalData(osg::Object& obj, osgDB::Input &fr) +bool ShadowVolume_readLocalData(osg::Object& /*obj*/, osgDB::Input& /*fr*/) { - osgShadow::ShadowVolume& ss = static_cast(obj); + // osgShadow::ShadowVolume& ss = static_cast(obj); bool itAdvanced = false; return itAdvanced; } -bool ShadowVolume_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +bool ShadowVolume_writeLocalData(const osg::Object& /*obj*/, osgDB::Output& /*fw*/) { - const osgShadow::ShadowVolume& ss = static_cast(obj); + // const osgShadow::ShadowVolume& ss = static_cast(obj); return true; } diff --git a/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp b/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp index 6b6da4748..795094662 100644 --- a/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp +++ b/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp @@ -73,9 +73,11 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter mkdir( dirname, 0700 ); #endif - system( command ); + if ( system( command ) ) { + return ReadResult::FILE_NOT_HANDLED; + } - osg::Group *grp = new osg::Group; + osg::ref_ptr grp = new osg::Group; osg::ref_ptr local_options = options ? static_cast(options->clone(osg::CopyOp::SHALLOW_COPY)) : new osgDB::ReaderWriter::Options; local_options->getDatabasePathList().push_front(dirname); @@ -97,12 +99,13 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter // note, is this the right command for windows? // is there any way of overiding the Y/N option? RO. sprintf( command, "erase %s", dirname ); - system( command ); #else sprintf( command, "rm -rf %s", dirname ); - system( command ); #endif + if ( system( command ) ) { + return ReadResult::FILE_NOT_HANDLED; + } if( grp->getNumChildren() == 0 ) { @@ -110,7 +113,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter return ReadResult::FILE_NOT_HANDLED; } - return grp; + return grp.get(); } diff --git a/src/osgPlugins/pdf/ReaderWriterPDF.cpp b/src/osgPlugins/pdf/ReaderWriterPDF.cpp index 66fbf6a73..dd6bb8812 100644 --- a/src/osgPlugins/pdf/ReaderWriterPDF.cpp +++ b/src/osgPlugins/pdf/ReaderWriterPDF.cpp @@ -31,9 +31,12 @@ class CairoImage : public osg::Referenced _context(0) {} - void create(unsigned int width, unsigned int height) + void create(int width, int height) { - if (_image->data() && width==_image->s() && height==_image->t()) return; + if (_image->data() && width==_image->s() && height==_image->t()) + { + return; + } osg::notify(osg::NOTICE)<<"Create cario surface/context "<getContext()); dirty(); - + + return true; } diff --git a/src/osgPlugins/shp/ESRIShape.cpp b/src/osgPlugins/shp/ESRIShape.cpp index 06f203697..ade244ae4 100644 --- a/src/osgPlugins/shp/ESRIShape.cpp +++ b/src/osgPlugins/shp/ESRIShape.cpp @@ -692,7 +692,7 @@ PolygonM::~PolygonM() delete[] parts; delete[] points; delete[] mArray; -}; +} bool PolygonM::read( int fd ) diff --git a/src/osgPlugins/tgz/ReaderWriterTGZ.cpp b/src/osgPlugins/tgz/ReaderWriterTGZ.cpp index b4777011b..78b5ec469 100644 --- a/src/osgPlugins/tgz/ReaderWriterTGZ.cpp +++ b/src/osgPlugins/tgz/ReaderWriterTGZ.cpp @@ -84,9 +84,11 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter osg::notify(osg::NOTICE)<<"Running command '"< grp = new osg::Group; osg::notify(osg::NOTICE)<<"Done"<getNumChildren() == 0 ) { - grp->unref(); return ReadResult::FILE_NOT_HANDLED; } - return grp; + return grp.get(); } diff --git a/src/osgPlugins/vnc/ReaderWriterVNC.cpp b/src/osgPlugins/vnc/ReaderWriterVNC.cpp index 3df74f8f6..962058036 100644 --- a/src/osgPlugins/vnc/ReaderWriterVNC.cpp +++ b/src/osgPlugins/vnc/ReaderWriterVNC.cpp @@ -286,6 +286,7 @@ bool LibVncImage::sendPointerEvent(int x, int y, int buttonMask) SendPointerEvent(_client ,x, y, buttonMask); return true; } + return false; } bool LibVncImage::sendKeyEvent(int key, bool keyDown) @@ -295,6 +296,7 @@ bool LibVncImage::sendKeyEvent(int key, bool keyDown) SendKeyEvent(_client, key, keyDown ? TRUE : FALSE); return true; } + return false; } diff --git a/src/osgPlugins/xine/ReaderWriterXine.cpp b/src/osgPlugins/xine/ReaderWriterXine.cpp index 39680e243..c28ee85a6 100644 --- a/src/osgPlugins/xine/ReaderWriterXine.cpp +++ b/src/osgPlugins/xine/ReaderWriterXine.cpp @@ -327,8 +327,8 @@ class ReaderWriterXine : public osgDB::ReaderWriter if(user_home) { char* cfgfile = NULL; - asprintf(&(cfgfile), "%s/.xine/config", user_home); - xine_config_load(_xine, cfgfile); + int result = asprintf(&(cfgfile), "%s/.xine/config", user_home); + if (result>0) xine_config_load(_xine, cfgfile); } xine_init(_xine); diff --git a/src/osgPlugins/zip/ReaderWriterZIP.cpp b/src/osgPlugins/zip/ReaderWriterZIP.cpp index d08d1c559..604e79175 100644 --- a/src/osgPlugins/zip/ReaderWriterZIP.cpp +++ b/src/osgPlugins/zip/ReaderWriterZIP.cpp @@ -71,11 +71,6 @@ class ReaderWriterZIP : public osgDB::ReaderWriter fileName.c_str(), dirname); } - osg::notify(osg::NOTICE)<<"Running command '"< grp = new osg::Group; osg::ref_ptr local_options = options ? static_cast(options->clone(osg::CopyOp::SHALLOW_COPY)) : new osgDB::ReaderWriter::Options; local_options->getDatabasePathList().push_front(dirname); @@ -117,20 +116,20 @@ class ReaderWriterZIP : public osgDB::ReaderWriter // note, is this the right command for windows? // is there any way of overiding the Y/N option? RO. sprintf( command, "erase /S /Q \"%s\"", dirname ); - system( command ); + int result = system( command ); #else sprintf( command, "rm -rf %s", dirname ); - system( command ); + int result = system( command ); #endif + if (result!=0) return ReadResult::ERROR_IN_READING_FILE; if( grp->getNumChildren() == 0 ) { - grp->unref(); return ReadResult::FILE_NOT_HANDLED; } - return grp; + return grp.get(); } };