Commit e7341acf authored by David E. DeMarle's avatar David E. DeMarle Committed by Kitware Robot

Merge topic 'fix-ospray-related-mac-crashes-REL' into release

59f7b0f7 patch ospray to fix a number of paraview crashes
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !619
parents 804a2727 59f7b0f7
Pipeline #142113 running with stage
......@@ -42,3 +42,5 @@ superbuild_add_extra_cmake_args(
-DOSPRAY_INSTALL_DIR:PATH=<INSTALL_DIR>)
superbuild_apply_patch(ospray type-conversion
"Fix type conversion error on icc 18.")
superbuild_apply_patch(ospray fix-stale-constructor-call
"Fixup constructor calls")
diff --git a/components/ospcommon/common.cpp b/components/ospcommon/common.cpp
index 70ba1c4..03adfd8 100644
--- a/components/ospcommon/common.cpp
+++ b/components/ospcommon/common.cpp
@@ -75,6 +75,14 @@ namespace ospcommon {
{
return LibraryRepository::getInstance()->getSymbol(name);
}
+ std::string getSymbolsLibrary(const std::string& name)
+ {
+ return LibraryRepository::getInstance()->getSymbolsLibrary(name);
+ }
+ bool libraryExists(const std::string& name)
+ {
+ return LibraryRepository::getInstance()->libraryExists(name);
+ }
} // ::ospcommon
diff --git a/components/ospcommon/common.h b/components/ospcommon/common.h
index 0e0ca66..3a36b1d 100644
--- a/components/ospcommon/common.h
+++ b/components/ospcommon/common.h
@@ -89,6 +89,8 @@ namespace ospcommon {
OSPCOMMON_INTERFACE void loadLibrary(const std::string &name);
OSPCOMMON_INTERFACE void loadDefaultLibrary();
OSPCOMMON_INTERFACE void *getSymbol(const std::string &name);
+ OSPCOMMON_INTERFACE std::string getSymbolsLibrary(const std::string &name);
+ OSPCOMMON_INTERFACE bool libraryExists(const std::string &name);
#ifdef _WIN32
# define osp_snprintf sprintf_s
diff --git a/components/ospcommon/library.cpp b/components/ospcommon/library.cpp
index 1d2e582..9aa6f99 100644
--- a/components/ospcommon/library.cpp
+++ b/components/ospcommon/library.cpp
@@ -316,6 +316,7 @@ namespace ospcommon {
{
for (auto &l : repo)
delete l.second;
+ repo.clear();
}
void LibraryRepository::add(const std::string &name)
@@ -334,6 +335,20 @@ namespace ospcommon {
return sym;
}
+ std::string LibraryRepository::getSymbolsLibrary(const std::string &name) const
+ {
+ void *sym = nullptr;
+ std::string rlib = "";
+ for (auto lib = repo.cbegin(); sym == nullptr && lib != repo.end(); ++lib)
+ {
+ sym = lib->second->getSymbol(name);
+ rlib = lib->first;
+ }
+
+ if (sym)
+ return rlib;
+ return "";
+ }
void LibraryRepository::addDefaultLibrary()
{
diff --git a/components/ospcommon/library.h b/components/ospcommon/library.h
index 3c7cae0..307a7ff 100644
--- a/components/ospcommon/library.h
+++ b/components/ospcommon/library.h
@@ -14,6 +14,8 @@
// limitations under the License. //
// ======================================================================== //
+#pragma once
+
#include "common.h"
// std
#include <map>
@@ -54,6 +56,9 @@ namespace ospcommon {
/* returns address of a symbol from any library in the repo */
void* getSymbol(const std::string& sym) const;
+ /* returns name of a library in the repo that holds a symbol */
+ std::string getSymbolsLibrary(const std::string& sym) const;
+
/* add the default library to the repo */
void addDefaultLibrary();
diff --git a/ospray/api/objectFactory.h b/ospray/api/objectFactory.h
index 593f8b1..c902bb2 100644
--- a/ospray/api/objectFactory.h
+++ b/ospray/api/objectFactory.h
@@ -17,6 +17,7 @@
#pragma once
#include "../common/OSPCommon.h"
+#include "ospcommon/library.h"
#include <map>
@@ -31,10 +32,11 @@ namespace ospray {
// Function pointers corresponding to each subtype.
static std::map<std::string, creationFunctionPointer> symbolRegistry;
+ static std::map<std::string, std::string> symbolsLibRegistry;
const auto type_string = stringForType(OSP_TYPE);
// Find the creation function for the subtype if not already known.
- if (symbolRegistry.count(type) == 0) {
+ if (symbolRegistry.count(type) == 0 || !libraryExists(symbolsLibRegistry[type])) {
postStatusMsg(2) << "#ospray: trying to look up "
<< type_string << " type '" << type
<< "' for the first time";
@@ -46,6 +48,8 @@ namespace ospray {
// Look for the named function.
symbolRegistry[type] =
(creationFunctionPointer)getSymbol(creationFunctionName);
+ symbolsLibRegistry[type] =
+ getSymbolsLibrary(creationFunctionName);
// The named function may not be found if the requested subtype is not
// known.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment