-
-
Notifications
You must be signed in to change notification settings - Fork 228
DisplayServer singleton error (windows) #1157
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
Comments
Are you sure this is related to the singleton? The failure in your code is Can you please reduce the code as much as possible? I.e. see if it's possible
Please also make sure there is no
We're not explicitly supporting that target, e.g. we don't run CI for it. I don't see why it should behave differently, but it's not the first time I've seen people having problems with that target on Windows. Is there a chance you can compile to the |
I didn’t know that x86_64-pc-windows-gnu is not supported. In any case, msvc will be better, you're right, but on Linux it’s a bit cumbersome to install everything. Therefore, I will wait with this for now. I can't provide my full code for certain reasons, which is why I gave such a minimal example. Here’s what I managed to understand:
All of this led me to the following conclusions:
But overall, we were lucky; I was able to recreate this error exactly. It works 100% the same. Honestly, I still don't understand what's wrong. Please correct me if I made any mistake. |
I've concluded that this error occurs due to the use of on_notification(). |
The problem you're facing is likely related to these issues:
ProblemThanks for the example! I don't have time to test it today or tomorrow, but it seems your problem can be reduced to this: #[derive(GodotClass)]
#[class(init, base=Node)]
struct RGlobal {
base: Base<Node>,
}
#[godot_api]
impl INode for RGlobal {
fn on_notification(&mut self, what: NodeNotification) {}
}
#[godot_api]
impl RGlobal {
#[func]
fn setWindowSize(&mut self) {
let mut displayServer: Gd<DisplayServer> = DisplayServer::singleton();
displayServer.window_set_position(Vector2i::new(1366, 768));
}
} In other words, fn setWindowSize(&mut self) // <- you will get a double-borrow error when acquiring a second exclusive reference: fn on_notification(&mut self, what: NodeNotification)
// ^^^^^^^^^ SolutionYou can solve this by acquiring a Not tested, but can you try this? #[func]
fn setWindowSize(&mut self) {
let mut displayServer: Gd<DisplayServer> = DisplayServer::singleton();
let _lock_self = self.base_mut(); // locks the &mut away for re-entrant exclusive access
displayServer.window_set_position(Vector2i::new(1366, 768));
} |
I checked, |
Thanks and glad it worked! I'll close this as solved then. For possible improvements to virtual methods like Also, |
I encountered an issue with singletons - it behaves as if my class continues to hold ownership of the singleton even after it's used in a method. I even tried using references, but the behavior remains the same. The error only occurs on Windows; everything works fine on Linux. I'm using the master version of gdext. There are no compilation errors, as expected, which suggests this might be a bug specific to the Windows build. I'm targeting x86_64-pc-windows-gnu.
rust:
godot:
error:
The text was updated successfully, but these errors were encountered: