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
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ IndentPPDirectives: AfterHash
ColumnLimit: 80
AlwaysBreakAfterDefinitionReturnType: All
PointerAlignment: Right
ForEachMacros: ['SENTRY_WITH_SCOPE', 'SENTRY_WITH_SCOPE_MUT', 'SENTRY_WITH_SCOPE_MUT_NO_FLUSH', 'SENTRY_WITH_OPTIONS', 'SENTRY_WITH_OPTIONS_MUT']
ForEachMacros: ['SENTRY_WITH_SCOPE', 'SENTRY_WITH_SCOPE_MUT', 'SENTRY_WITH_SCOPE_MUT_NO_FLUSH', 'SENTRY_WITH_OPTIONS', 'SENTRY_WITH_OPTIONS_MUT', 'DATA_READ_LOCK', 'DATA_WRITE_LOCK']
InsertNewlineAtEOF: True
2 changes: 1 addition & 1 deletion src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ crashpad_handler(int signum, siginfo_t *info, ucontext_t *user_context)
// written above and stays breadcrumb-free
SENTRY_WITH_SCOPE (scope) {
sentry_value_set_by_key(crash_event, "breadcrumbs",
sentry__ringbuffer_to_list(scope->breadcrumbs));
sentry__scope_breadcrumbs_to_list(scope));
}

sentry__session_replay_flush_pending(
Expand Down
5 changes: 4 additions & 1 deletion src/backends/sentry_backend_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,14 @@ native_backend_write_attachments(const sentry_path_t *event_path)
return;
}
SENTRY_WITH_SCOPE (scope) {
sentry_value_t attachments = scope->attachments;
sentry_value_t attachments = sentry__scope_clone_attachments(scope);
if (sentry_value_get_length(attachments) == 0) {
sentry_value_decref(attachments);
continue;
}
sentry_path_t *run_path = sentry__path_dir(event_path);
if (!run_path) {
sentry_value_decref(attachments);
continue;
}
sentry_path_t *attach_list_path
Expand Down Expand Up @@ -785,6 +787,7 @@ native_backend_write_attachments(const sentry_path_t *event_path)
sentry__path_free(attach_list_path);
}
sentry__path_free(run_path);
sentry_value_decref(attachments);
}
}

Expand Down
38 changes: 21 additions & 17 deletions src/integrations/sentry_integration_wer.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ wer_remove_attachment(void *UNUSED(data), sentry_value_t attachment)
}
}

static void
wer_for_each_attachment(
sentry_scope_t *scope, void *data, void (*callback)(void *, sentry_value_t))
{
sentry_value_t attachments = sentry__scope_clone_attachments(scope);
size_t len = sentry_value_get_length(attachments);
for (size_t i = 0; i < len; i++) {
callback(data, sentry_value_get_by_index(attachments, i));
}
sentry_value_decref(attachments);
}

static void
wer_cleanup_tag(const char *key, sentry_value_t UNUSED(value), void *data)
{
Expand All @@ -207,13 +219,11 @@ wer_clear(void *data)
return;
}

sentry__value_foreach_key_value(scope->tags, wer_cleanup_tag, wer_data);
sentry_value_t tags = sentry__scope_ref_tags(scope);
sentry__value_foreach_key_value(tags, wer_cleanup_tag, wer_data);
sentry_value_decref(tags);

size_t len = sentry_value_get_length(scope->attachments);
for (size_t i = 0; i < len; i++) {
wer_remove_attachment(
wer_data, sentry_value_get_by_index(scope->attachments, i));
}
wer_for_each_attachment(scope, wer_data, wer_remove_attachment);
}

static void
Expand All @@ -238,11 +248,7 @@ register_wer(
if (sentry__scope_add_observer(scope, observer)) {
wer_data->scope = scope;
wer_data->observer = observer;
size_t len = sentry_value_get_length(scope->attachments);
for (size_t i = 0; i < len; i++) {
wer_add_attachment(
wer_data, sentry_value_get_by_index(scope->attachments, i));
}
wer_for_each_attachment(scope, wer_data, wer_add_attachment);
}
}

Expand All @@ -256,13 +262,11 @@ unregister_wer(
return;
}

sentry__value_foreach_key_value(scope->tags, wer_cleanup_tag, wer_data);
sentry_value_t tags = sentry__scope_ref_tags(scope);
sentry__value_foreach_key_value(tags, wer_cleanup_tag, wer_data);
sentry_value_decref(tags);

size_t len = sentry_value_get_length(scope->attachments);
for (size_t i = 0; i < len; i++) {
wer_remove_attachment(
wer_data, sentry_value_get_by_index(scope->attachments, i));
}
wer_for_each_attachment(scope, wer_data, wer_remove_attachment);

sentry__scope_remove_observer(scope, wer_data->observer);
wer_data->scope = NULL;
Expand Down
Loading
Loading