Skip to content

Commit 73c4aa7

Browse files
authored
Merge pull request #1107 from PgBiel/undo-nothreads-fix
Undo Wasm threading fix on panic context tracking
2 parents 033a131 + 5831542 commit 73c4aa7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

godot-core/src/private.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use sys::out;
1717

1818
#[cfg(feature = "trace")]
1919
pub use crate::meta::trace;
20-
#[cfg(all(debug_assertions, not(wasm_nothreads)))]
20+
#[cfg(debug_assertions)]
2121
use std::cell::RefCell;
2222

2323
use crate::global::godot_error;
@@ -321,12 +321,12 @@ pub(crate) fn has_error_print_level(level: u8) -> bool {
321321
/// Internal type used to store context information for debug purposes. Debug context is stored on the thread-local
322322
/// ERROR_CONTEXT_STACK, which can later be used to retrieve the current context in the event of a panic. This value
323323
/// probably shouldn't be used directly; use ['get_gdext_panic_context()'](get_gdext_panic_context) instead.
324-
#[cfg(all(debug_assertions, not(wasm_nothreads)))]
324+
#[cfg(debug_assertions)]
325325
struct ScopedFunctionStack {
326326
functions: Vec<*const dyn Fn() -> String>,
327327
}
328328

329-
#[cfg(all(debug_assertions, not(wasm_nothreads)))]
329+
#[cfg(debug_assertions)]
330330
impl ScopedFunctionStack {
331331
/// # Safety
332332
/// Function must be removed (using [`pop_function()`](Self::pop_function)) before lifetime is invalidated.
@@ -351,7 +351,7 @@ impl ScopedFunctionStack {
351351
}
352352
}
353353

354-
#[cfg(all(debug_assertions, not(wasm_nothreads)))]
354+
#[cfg(debug_assertions)]
355355
thread_local! {
356356
static ERROR_CONTEXT_STACK: RefCell<ScopedFunctionStack> = const {
357357
RefCell::new(ScopedFunctionStack { functions: Vec::new() })
@@ -360,10 +360,10 @@ thread_local! {
360360

361361
// Value may return `None`, even from panic hook, if called from a non-Godot thread.
362362
pub fn get_gdext_panic_context() -> Option<String> {
363-
#[cfg(all(debug_assertions, not(wasm_nothreads)))]
363+
#[cfg(debug_assertions)]
364364
return ERROR_CONTEXT_STACK.with(|cell| cell.borrow().get_last());
365365

366-
#[cfg(not(all(debug_assertions, not(wasm_nothreads))))]
366+
#[cfg(not(debug_assertions))]
367367
None
368368
}
369369

@@ -378,10 +378,10 @@ where
378378
E: Fn() -> String,
379379
F: FnOnce() -> R + std::panic::UnwindSafe,
380380
{
381-
#[cfg(not(all(debug_assertions, not(wasm_nothreads))))]
382-
let _ = error_context; // Unused in Release or `wasm_nothreads` builds.
381+
#[cfg(not(debug_assertions))]
382+
let _ = error_context; // Unused in Release.
383383

384-
#[cfg(all(debug_assertions, not(wasm_nothreads)))]
384+
#[cfg(debug_assertions)]
385385
ERROR_CONTEXT_STACK.with(|cell| unsafe {
386386
// SAFETY: &error_context is valid for lifetime of function, and is removed from LAST_ERROR_CONTEXT before end of function.
387387
cell.borrow_mut().push_function(&error_context)
@@ -390,7 +390,7 @@ where
390390
let result =
391391
std::panic::catch_unwind(code).map_err(|payload| extract_panic_message(payload.as_ref()));
392392

393-
#[cfg(all(debug_assertions, not(wasm_nothreads)))]
393+
#[cfg(debug_assertions)]
394394
ERROR_CONTEXT_STACK.with(|cell| cell.borrow_mut().pop_function());
395395
result
396396
}

0 commit comments

Comments
 (0)