Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
### 🐞 Bug fixes

- *...Add new stuff here...*
- [core] Fix thread-unsafe headless OpenGL display singleton initialization [#4332](https://github.com/maplibre/maplibre-native/pull/4332)
- [macos] Fix `mlt-cpp` and `mbgl-vendor-icu` not being included in the amalgamation
- [core] Fix memory access violation exception in vector_tile_data.cpp [#632](https://github.com/maplibre/maplibre-native/pull/632)
- [iOS] Fix a bug where the compass was determined to be misplaced when hidden [#498](https://github.com/maplibre/maplibre-native/pull/498).
Expand Down
10 changes: 4 additions & 6 deletions platform/linux/src/headless_backend_egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <EGL/egl.h>

#include <cassert>
#include <memory>
#include <sstream>

namespace mbgl {
Expand Down Expand Up @@ -51,12 +52,9 @@ class EGLDisplayConfig {
~EGLDisplayConfig() { eglTerminate(display); }

static std::shared_ptr<const EGLDisplayConfig> create() {
static std::weak_ptr<const EGLDisplayConfig> instance;
auto shared = instance.lock();
if (!shared) {
instance = shared = std::make_shared<EGLDisplayConfig>(Key{});
}
return shared;
// C++11 magic static guarantees thread-safe one-shot initialization.
static const auto instance = std::make_shared<EGLDisplayConfig>(Key{});
return instance;
}

public:
Expand Down
10 changes: 4 additions & 6 deletions platform/linux/src/headless_backend_glx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <mbgl/util/logging.hpp>

#include <cassert>
#include <memory>

#ifdef CI_BUILD
#include <chrono>
Expand Down Expand Up @@ -80,12 +81,9 @@ class GLXDisplayConfig {
}

static std::shared_ptr<const GLXDisplayConfig> create() {
static std::weak_ptr<const GLXDisplayConfig> instance;
auto shared = instance.lock();
if (!shared) {
instance = shared = std::make_shared<GLXDisplayConfig>(Key{});
}
return shared;
// C++11 magic static guarantees thread-safe one-shot initialization.
static const auto instance = std::make_shared<GLXDisplayConfig>(Key{});
return instance;
}

public:
Expand Down
10 changes: 4 additions & 6 deletions platform/windows/src/headless_backend_egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <EGL/egl.h>

#include <cassert>
#include <memory>
#include <sstream>
#include <iomanip>

Expand Down Expand Up @@ -53,12 +54,9 @@ class EGLDisplayConfig {
~EGLDisplayConfig() { eglTerminate(display); }

static std::shared_ptr<const EGLDisplayConfig> create() {
static std::weak_ptr<const EGLDisplayConfig> instance;
auto shared = instance.lock();
if (!shared) {
instance = shared = std::make_shared<EGLDisplayConfig>(Key{});
}
return shared;
// C++11 magic static guarantees thread-safe one-shot initialization.
static const auto instance = std::make_shared<EGLDisplayConfig>(Key{});
return instance;
}

public:
Expand Down