[gjs: 2/3] context: Only show a critical error if unregistering an unknown promise
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/3] context: Only show a critical error if unregistering an unknown promise
- Date: Wed, 23 Feb 2022 04:57:01 +0000 (UTC)
commit 865d2ae27b853848157215cc60e4888575f13200
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Tue Feb 22 04:18:40 2022 +0100
context: Only show a critical error if unregistering an unknown promise
In case a promise handled is removed too early or never added we may
have a bug, but not enough critical to crash.
gjs/context.cpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 0ba6b250a..12eb0921c 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -1150,10 +1150,14 @@ void GjsContextPrivate::register_unhandled_promise_rejection(
}
void GjsContextPrivate::unregister_unhandled_promise_rejection(uint64_t id) {
- // Return value unused in G_DISABLE_ASSERT case
- [[maybe_unused]] size_t erased = m_unhandled_rejection_stacks.erase(id);
- g_assert(((void)"Handler attached to rejected promise that wasn't "
- "previously marked as unhandled", erased == 1));
+ size_t erased = m_unhandled_rejection_stacks.erase(id);
+ if (erased != 1) {
+ g_critical("Promise %" G_GUINT64_FORMAT
+ " Handler attached to rejected promise that wasn't "
+ "previously marked as unhandled or that we wrongly reported "
+ "as unhandled",
+ id);
+ }
}
void GjsContextPrivate::async_closure_enqueue_for_gc(Gjs::Closure* trampoline) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]