[Bf-blender-cvs] [c17ccb1] openvdb: Definitely remove the exception safety code.

Kévin Dietrich noreply at git.blender.org
Mon Aug 3 22:03:08 CEST 2015


Commit: c17ccb165e87af1d29ada13a0c09be5a1a46b8c9
Author: Kévin Dietrich
Date:   Mon Aug 3 21:38:46 2015 +0200
Branches: openvdb
https://developer.blender.org/rBc17ccb165e87af1d29ada13a0c09be5a1a46b8c9

Definitely remove the exception safety code.

It was first included as a safety net, but after close inspection of
where exceptions are used in the OpenVDB library, it appears that about
half of them are not used at all whilst the others are fairly dumb and
can be avoided gracefully (e.g. openvdb::ValueError is thrown in some
place if a negative value is passed, so don't pass a negative value ;).

Also the only place where it was used could hardly result in an
exception (only happens if the file is not a .vdb file, so let's trust
the user on that).

===================================================================

M	intern/openvdb/openvdb_capi.cc
M	intern/openvdb/openvdb_capi.h
M	intern/openvdb/openvdb_util.cc
M	intern/openvdb/openvdb_util.h

===================================================================

diff --git a/intern/openvdb/openvdb_capi.cc b/intern/openvdb/openvdb_capi.cc
index ba29999..99b024c 100644
--- a/intern/openvdb/openvdb_capi.cc
+++ b/intern/openvdb/openvdb_capi.cc
@@ -42,30 +42,24 @@ void OpenVDB_get_grid_info(const char *filename, OpenVDBGridInfoCallback cb, voi
 
 	using namespace openvdb;
 
-	int ret = OPENVDB_NO_ERROR;
 	initialize();
-	
-	try {
-		io::File file(filename);
-		file.open();
-		
-		GridPtrVecPtr grids = file.getGrids();
-		int grid_num = grids->size();
-		
-		for (size_t i = 0; i < grid_num; ++i) {
-			GridBase::ConstPtr grid = (*grids)[i];
-			
-			std::string name = grid->getName();
-			std::string value_type = grid->valueType();
-			bool is_color = false;
-			if (grid->getMetadata< TypedMetadata<bool> >("is_color"))
-				is_color = grid->metaValue<bool>("is_color");
-			
-			cb(userdata, name.c_str(), value_type.c_str(), is_color);
-		}
-	}
-	catch (...) {
-		catch_exception(ret);
+
+	io::File file(filename);
+	file.open();
+
+	GridPtrVecPtr grids = file.getGrids();
+	int grid_num = grids->size();
+
+	for (size_t i = 0; i < grid_num; ++i) {
+		GridBase::ConstPtr grid = (*grids)[i];
+
+		std::string name = grid->getName();
+		std::string value_type = grid->valueType();
+		bool is_color = false;
+		if (grid->getMetadata< TypedMetadata<bool> >("is_color"))
+			is_color = grid->metaValue<bool>("is_color");
+
+		cb(userdata, name.c_str(), value_type.c_str(), is_color);
 	}
 }
 
diff --git a/intern/openvdb/openvdb_capi.h b/intern/openvdb/openvdb_capi.h
index 8fe5860..9c9e341 100644
--- a/intern/openvdb/openvdb_capi.h
+++ b/intern/openvdb/openvdb_capi.h
@@ -42,21 +42,6 @@ typedef void (*OpenVDBGridInfoCallback)(void *userdata, const char *name, const
 void OpenVDB_get_grid_info(const char *filename, OpenVDBGridInfoCallback cb, void *userdata);
 
 enum {
-	OPENVDB_NO_ERROR      = 0,
-	OPENVDB_ARITHM_ERROR  = 1,
-	OPENVDB_ILLEGAL_ERROR = 2,
-	OPENVDB_INDEX_ERROR   = 3,
-	OPENVDB_IO_ERROR      = 4,
-	OPENVDB_KEY_ERROR     = 5,
-	OPENVDB_LOOKUP_ERROR  = 6,
-	OPENVDB_IMPL_ERROR    = 7,
-	OPENVDB_REF_ERROR     = 8,
-	OPENVDB_TYPE_ERROR    = 9,
-	OPENVDB_VALUE_ERROR   = 10,
-	OPENVDB_UNKNOWN_ERROR = 11,
-};
-
-enum {
 	VEC_INVARIANT = 0,
 	VEC_COVARIANT = 1,
 	VEC_COVARIANT_NORMALIZE = 2,
diff --git a/intern/openvdb/openvdb_util.cc b/intern/openvdb/openvdb_util.cc
index f9ea180..9d23877 100644
--- a/intern/openvdb/openvdb_util.cc
+++ b/intern/openvdb/openvdb_util.cc
@@ -23,62 +23,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#include <openvdb/Exceptions.h>
-
-#include "openvdb_capi.h"
 #include "openvdb_util.h"
 
-void catch_exception(int &ret)
-{
-	try {
-		throw;
-	}
-	catch (const openvdb::ArithmeticError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_ARITHM_ERROR;
-	}
-	catch (const openvdb::IllegalValueException &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_ILLEGAL_ERROR;
-	}
-	catch (const openvdb::IndexError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_INDEX_ERROR;
-	}
-	catch (const openvdb::IoError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_IO_ERROR;
-	}
-	catch (const openvdb::KeyError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_KEY_ERROR;
-	}
-	catch (const openvdb::LookupError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_LOOKUP_ERROR;
-	}
-	catch (const openvdb::NotImplementedError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_IMPL_ERROR;
-	}
-	catch (const openvdb::ReferenceError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_REF_ERROR;
-	}
-	catch (const openvdb::TypeError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_TYPE_ERROR;
-	}
-	catch (const openvdb::ValueError &e) {
-		std::cerr << e.what() << std::endl;
-		ret = OPENVDB_VALUE_ERROR;
-	}
-	catch (...) {
-		std::cerr << "Unknown error in OpenVDB library..." << std::endl;
-		ret = OPENVDB_UNKNOWN_ERROR;
-	}
-}
-
 #ifdef _WIN32
 
 #include <windows.h>
diff --git a/intern/openvdb/openvdb_util.h b/intern/openvdb/openvdb_util.h
index ad83dbb..2da3c53 100644
--- a/intern/openvdb/openvdb_util.h
+++ b/intern/openvdb/openvdb_util.h
@@ -29,8 +29,6 @@
 #include <cstdio>
 #include <string>
 
-void catch_exception(int &ret);
-
 double time_dt();
 
 /* A utility class which prints the time elapsed during its lifetime, useful for




More information about the Bf-blender-cvs mailing list