Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -6,6 +6,7 @@

- Prevent feedback loops in SentryLogger ([#275](https://github.com/getsentry/sentry-godot/pull/275))
- Fix `release` option not honored if set to a custom value in the project settings, and fix parsing of `app_name`/`app_version` replacement tokens if set via a configuration script. ([#276](https://github.com/getsentry/sentry-godot/pull/276))
- Remove `libatomic.so.1` dependency on Linux ([#278](https://github.com/getsentry/sentry-godot/pull/278))

## 1.0.0-alpha.2

Expand Down
1 change: 0 additions & 1 deletion modules/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ elif platform == "linux":
env.Append(
LIBS=[
"curl",
"atomic"
]
)
elif platform == "macos":
Expand Down
22 changes: 19 additions & 3 deletions src/sentry/native/native_sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,20 @@ String NativeSDK::capture_message(const String &p_message, Level p_level) {
p_message.utf8().get_data());

sentry_uuid_t uuid = sentry_capture_event(event);
last_uuid.store(uuid, std::memory_order_release);

last_uuid_mutex->lock();
last_uuid = uuid;
last_uuid_mutex->unlock();

return _uuid_as_string(uuid);
}

String NativeSDK::get_last_event_id() {
return _uuid_as_string(last_uuid.load(std::memory_order_acquire));
last_uuid_mutex->lock();
String uuid_str = _uuid_as_string(last_uuid);
last_uuid_mutex->unlock();

return uuid_str;
}

Ref<SentryEvent> NativeSDK::create_event() {
Expand All @@ -206,7 +214,11 @@ String NativeSDK::capture_event(const Ref<SentryEvent> &p_event) {
sentry_value_t event = native_event->get_native_value();
sentry_value_incref(event); // Keep ownership.
sentry_uuid_t uuid = sentry_capture_event(event);
last_uuid.store(uuid, std::memory_order_release);

last_uuid_mutex->lock();
last_uuid = uuid;
last_uuid_mutex->unlock();

return _uuid_as_string(uuid);
}

Expand Down Expand Up @@ -318,6 +330,10 @@ void NativeSDK::initialize(const PackedStringArray &p_global_attachments) {
}
}

NativeSDK::NativeSDK() {
last_uuid_mutex.instantiate();
}

NativeSDK::~NativeSDK() {
sentry_close();
}
Expand Down
6 changes: 4 additions & 2 deletions src/sentry/native/native_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#include "sentry/internal_sdk.h"

#include <sentry.h>
#include <atomic>
#include <godot_cpp/classes/mutex.hpp>

namespace sentry {

// Internal SDK utilizing sentry-native.
class NativeSDK : public InternalSDK {
private:
std::atomic<sentry_uuid_t> last_uuid;
sentry_uuid_t last_uuid;
Ref<Mutex> last_uuid_mutex;
bool initialized = false;

public:
Expand All @@ -37,6 +38,7 @@ class NativeSDK : public InternalSDK {

virtual void initialize(const PackedStringArray &p_global_attachments) override;

NativeSDK();
virtual ~NativeSDK() override;
};

Expand Down
Loading