Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gwaldron/osgearth
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbeverage committed Apr 2, 2024
2 parents 59a82a7 + cd98f95 commit 74d0bf9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 56 deletions.
7 changes: 7 additions & 0 deletions src/osgEarth/ImageLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ ImageLayer::openImplementation()
}
}

for (auto layer : _postLayers)
{
Status s = layer->open(getReadOptions());
if (s.isError())
return s;
}

return Status::NoError;
}

Expand Down
1 change: 0 additions & 1 deletion src/osgEarth/MapNode
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ namespace osgEarth

private:

osg::ref_ptr<Registry> _registry;
osg::ref_ptr<Map> _map;
osg::Group* _layerNodes;
unsigned _lastNumBlacklistedFilenames;
Expand Down
2 changes: 1 addition & 1 deletion src/osgEarth/MapNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ MapNode::init()

// Make sure the Registry is not destroyed until we are done using
// it (in ~MapNode).
_registry = Registry::instance();
//_registry = Registry::instance();

// the default SSE for all supporting geometries
_sseU = new osg::Uniform("oe_sse", options().screenSpaceError().get());
Expand Down
5 changes: 3 additions & 2 deletions src/osgEarth/Registry
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace osgEarth
/**
* Application-wide global repository.
*/
class OSGEARTH_EXPORT Registry : public osg::Referenced
class OSGEARTH_EXPORT Registry // : public osg::Referenced
{
public:
//! Access the global Registry singleton.
Expand Down Expand Up @@ -309,8 +309,9 @@ namespace osgEarth
return dynamic_cast<T*>(s.get());
}

protected:
virtual ~Registry();

protected:
Registry();

mutable std::mutex _regMutex;
Expand Down
67 changes: 23 additions & 44 deletions src/osgEarth/Registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,11 @@ using namespace osgEarth;

#define LC "[Registry] "

namespace
{
osg::ref_ptr<osgEarth::Registry> g_registry = nullptr;
}

void osgEarth::initialize()
{
// Create the registry singleton.
// It will be destroyed on program exit automatically.
if (!g_registry.valid())
{
g_registry = Registry::instance();
}

// Query the system capabilities
g_registry->getCapabilities();

Registry::instance()->getCapabilities();

// Tell the weetjobs library how to set a thread name
jobs::set_thread_name_function([](const char* value) {
osgEarth::setThreadName(value);
Expand Down Expand Up @@ -291,48 +279,39 @@ Registry::~Registry()
OE_INFO << "Goodbye." << std::endl;
}

//// Destroy the registry explicitly: this is called in an atexit() hook. See comment in
//// Registry::instance(bool reset).
//void destroyRegistry()
//{
// if (g_registry.valid())
// {
// g_registry->release();
// g_registry = nullptr;
// }
//}
// Destroy the registry explicitly: this is called in an atexit() hook. See comment in
// Registry::instance(bool reset).
namespace
{
static bool g_registry_created = false;
static Registry* g_registry = nullptr;

void destroyRegistry()
{
if (g_registry)
{
g_registry->release();
delete g_registry;
g_registry = nullptr;
}
}
}

Registry*
Registry::instance()
{
// Make sure the gdal mutex is created before the Registry so it will still be around when the registry is destroyed statically.
// This is to prevent crash on exit where the gdal mutex is deleted before the registry is.

//static bool s_registryInit = false;

// Create registry the first time through, explicitly rather than depending on static object
// initialization order, which is undefined in c++ across separate compilation units. An
// explicit hook is registered to tear it down on exit. atexit() hooks are run on exit in
// the reverse order of their registration during setup.
if (!g_registry.valid())
if (!g_registry && !g_registry_created)
{
g_registry = new Registry();
g_registry_created = true;
std::atexit(destroyRegistry);
}

//if (!s_registryInit)
//{
// s_registryInit = true;
// s_registry = new Registry;
// std::atexit(destroyRegistry);
//}

//if (reset)
//{
// s_registry->release();
// s_registry = new Registry();
//}

return g_registry.get();
return g_registry;
}

void
Expand Down
15 changes: 7 additions & 8 deletions src/osgEarthProcedural/BiomeLayer
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ namespace osgEarth

struct OSGEARTHPROCEDURAL_EXPORT LandCoverSample
{
OE_OPTION(std::string, biomeid);
OE_OPTION(float, dense);
OE_OPTION(float, lush);
OE_OPTION(float, rugged);
OE_OPTION(std::string, material);
OE_OPTION(std::string, soiltype);
OE_OPTION(std::string, biomeid, {});
OE_OPTION(float, dense, 0.0f);
OE_OPTION(float, lush, 0.0f);
OE_OPTION(float, rugged, 0.0f);
OE_OPTION(std::string, material, {});
OE_OPTION(std::string, soiltype, {});
OE_PROPERTY(std::vector<std::string>, traits);

LandCoverSample() { }
LandCoverSample() = default;

LandCoverSample(const Config& conf)
{
Expand Down Expand Up @@ -86,7 +86,6 @@ namespace osgEarth
bool operator < (const LandCoverSample& rhs) const
{
OE_OPTION_LESS(biomeid, rhs.biomeid);
//OE_OPTION_LESS(traits, rhs.traits);
OE_OPTION_LESS(dense, rhs.dense);
OE_OPTION_LESS(lush, rhs.lush);
OE_OPTION_LESS(rugged, rhs.rugged);
Expand Down

0 comments on commit 74d0bf9

Please sign in to comment.