diff --git a/CMakeLists.txt b/CMakeLists.txt index 7136b5269..d976eb87f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,3 +165,14 @@ configure_file ( add_subdirectory(src) add_subdirectory(utils) + +#----------------------------------------------------------------------------- +### uninstall target +#----------------------------------------------------------------------------- +CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) +ADD_CUSTOM_TARGET(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + diff --git a/CMakeModules/cmake_uninstall.cmake.in b/CMakeModules/cmake_uninstall.cmake.in new file mode 100644 index 000000000..3b6a9d03c --- /dev/null +++ b/CMakeModules/cmake_uninstall.cmake.in @@ -0,0 +1,22 @@ +IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +ENDIF() + +FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +STRING(REGEX REPLACE "\n" ";" files "${files}") + +FOREACH(file ${files}) + MESSAGE(STATUS "Uninstalling \"${file}\"") + IF(EXISTS "${file}") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF(NOT "${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"") + ENDIF() + ELSE() + MESSAGE(STATUS "File \"${file}\" does not exist.") + ENDIF() +ENDFOREACH() diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 72c964c04..158d852e5 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -186,8 +186,16 @@ static naRef f_getprop(naContext c, naRef me, int argc, naRef* args) case props::BOOL: case props::INT: case props::LONG: case props::FLOAT: case props::DOUBLE: - return naNum(p->getDoubleValue()); - + { + double dv = p->getDoubleValue(); + if (osg::isNaN(dv)) { + SG_LOG(SG_GENERAL, SG_ALERT, "Nasal getprop: property " << p->getPath() << " is NaN"); + naRuntimeError(c, "getprop() would have read NaN"); + } + + return naNum(dv); + } + case props::STRING: case props::UNSPECIFIED: { @@ -234,6 +242,11 @@ static naRef f_setprop(naContext c, naRef me, int argc, naRef* args) naRef n = naNumValue(val); if(naIsNil(n)) naRuntimeError(c, "setprop() value is not string or number"); + + if (osg::isNaN(n.num)) { + naRuntimeError(c, "setprop() passed a NaN"); + } + result = props->setDoubleValue(buf, n.num); } } catch (const string& err) { diff --git a/src/Scripting/nasal-props.cxx b/src/Scripting/nasal-props.cxx index 9f309903a..0ea341b08 100644 --- a/src/Scripting/nasal-props.cxx +++ b/src/Scripting/nasal-props.cxx @@ -169,7 +169,16 @@ static naRef f_getValue(naContext c, naRef me, int argc, naRef* args) case props::BOOL: case props::INT: case props::LONG: case props::FLOAT: case props::DOUBLE: - return naNum((*node)->getDoubleValue()); + { + double dv = (*node)->getDoubleValue(); + if (osg::isNaN(dv)) { + SG_LOG(SG_GENERAL, SG_ALERT, "Nasal getValue: property " << (*node)->getPath() << " is NaN"); + naRuntimeError(c, "props.getValue() would have read NaN"); + } + + return naNum(dv); + } + case props::STRING: case props::UNSPECIFIED: return NASTR((*node)->getStringValue()); @@ -217,7 +226,13 @@ static naRef f_setValue(naContext c, naRef me, int argc, naRef* args) naRef n = naNumValue(val); if(naIsNil(n)) naRuntimeError(c, "props.setValue() with non-number"); - result = (*node)->setDoubleValue(naNumValue(val).num); + + double d = naNumValue(val).num; + if (osg::isNaN(d)) { + naRuntimeError(c, "props.setValue() passed a NaN"); + } + + result = (*node)->setDoubleValue(d); } return naNum(result); } @@ -250,8 +265,13 @@ static naRef f_setDoubleValue(naContext c, naRef me, int argc, naRef* args) { NODEARG(); naRef r = naNumValue(naVec_get(argv, 0)); - if(naIsNil(r)) + if (naIsNil(r)) naRuntimeError(c, "props.setDoubleValue() with non-number"); + + if (osg::isNaN(r.num)) { + naRuntimeError(c, "props.setDoubleValue() passed a NaN"); + } + return naNum((*node)->setDoubleValue(r.num)); }