Skip to content

Typed signals in another file are private #1073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
austin226 opened this issue Mar 12, 2025 · 3 comments · Fixed by #1075
Closed

Typed signals in another file are private #1073

austin226 opened this issue Mar 12, 2025 · 3 comments · Fixed by #1075

Comments

@austin226
Copy link

In signal_test.rs, the test signal_symbols_external illustrates that we can connect to an external object's signals by using the emitter.signals() method.

However, if Emitter is located in another file, its signals are private from the perspective of the receiver. Attempting to make the signals public results in a compilation error:

#[signal] must not have a visibility specifier; signals are always public

For instance if I make the following change, the compiler gives me an error:

diff --git a/itest/rust/src/builtin_tests/containers/signal_test.rs b/itest/rust/src/builtin_tests/containers/signal_test.rs
index 6aa40494..645082c7 100644
--- a/itest/rust/src/builtin_tests/containers/signal_test.rs
+++ b/itest/rust/src/builtin_tests/containers/signal_test.rs
@@ -247,7 +247,7 @@ static LAST_STATIC_FUNCTION_ARG: Global<i64> = Global::default();

 #[derive(GodotClass)]
 #[class(init, base=Object)]
-struct Emitter {
+pub struct Emitter {
     _base: Base<Object>,
     #[cfg(since_api = "4.2")]
     last_received_int: i64,
diff --git a/itest/rust/src/builtin_tests/containers/variant_test.rs b/itest/rust/src/builtin_tests/containers/variant_test.rs
index 89208048..33f7df09 100644
--- a/itest/rust/src/builtin_tests/containers/variant_test.rs
+++ b/itest/rust/src/builtin_tests/containers/variant_test.rs
@@ -7,6 +7,7 @@

 use std::cmp::Ordering;
 use std::fmt::Display;
+use crate::builtin_tests::containers::signal_test::Emitter;

 use godot::builtin::{
     array, dict, varray, Array, GString, NodePath, Signal, StringName, Variant, Vector2, Vector3,
@@ -28,6 +29,9 @@ const TEST_BASIS: Basis = Basis::from_rows(

 #[itest]
 fn variant_nil() {
+    let emitter = Emitter::new_alloc();
+    let mut sig = emitter.signals().signal_int();
+
     let variant = Variant::nil();
     assert!(variant.is_nil());
function `signal_int` is private
@ColinWttt
Copy link
Contributor

ColinWttt commented Mar 12, 2025

This was fixed in the “bugfix/signal-visibility” branch, and the Godot class must also be marked as pub currently.

godot ={ git = "https://github.com/godot-rust/gdext" , branch="bugfix/signal-visibility"}

@Bromeon
Copy link
Member

Bromeon commented Mar 12, 2025

Note that my branch still needs some improvements and isn't ready as-is. See #1061 (comment)

@Bromeon
Copy link
Member

Bromeon commented Mar 12, 2025

@austin226 @ColinWttt if you have the chance, let me know what you think of #1075 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants