Added OSG_CPP_EXCEPTIONS_AVAILABLE cmake option to enable optional build of plugins and examples that required C++ exceptions
This commit is contained in:
@@ -51,7 +51,11 @@ private:
|
||||
|
||||
void user_error_fn(png_structp png_ptr, png_const_charp error_msg)
|
||||
{
|
||||
#ifdef OSG_CPP_EXCEPTIONS_AVAILABLE
|
||||
throw PNGError(error_msg);
|
||||
#else
|
||||
osg::notify(osg::WARN) << "PNG lib warning : " << error_msg << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
|
||||
@@ -166,9 +170,10 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
||||
// Set custom error handlers
|
||||
png_set_error_fn(png, png_get_error_ptr(png), user_error_fn, user_warning_fn);
|
||||
|
||||
#ifdef OSG_CPP_EXCEPTIONS_AVAILABLE
|
||||
try
|
||||
#endif
|
||||
{
|
||||
|
||||
info = png_create_info_struct(png);
|
||||
endinfo = png_create_info_struct(png);
|
||||
|
||||
@@ -300,13 +305,16 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
||||
osg::Image::USE_NEW_DELETE);
|
||||
|
||||
return pOsgImage;
|
||||
|
||||
}
|
||||
#ifdef OSG_CPP_EXCEPTIONS_AVAILABLE
|
||||
catch (PNGError& err)
|
||||
{
|
||||
osg::notify(osg::WARN) << err << std::endl;
|
||||
png_destroy_read_struct(&png, &info, &endinfo);
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int getCompressionLevel(const osgDB::ReaderWriter::Options *options) const
|
||||
|
||||
Reference in New Issue
Block a user