@@ -154,12 +154,12 @@ fn handle_recognizes_direct_object_disconnect() {
154
154
155
155
#[ itest]
156
156
fn test_handle_after_freeing_broadcaster ( ) {
157
- test_freed_nodes ( true ) ;
157
+ test_freed_nodes_handles ( true ) ;
158
158
}
159
159
160
160
#[ itest]
161
161
fn test_handle_after_freeing_receiver ( ) {
162
- test_freed_nodes ( false ) ;
162
+ test_freed_nodes_handles ( false ) ;
163
163
}
164
164
165
165
// Helper functions:
@@ -233,7 +233,7 @@ fn test_handle_recognizes_non_valid_state(disconnect_function: impl FnOnce(&mut
233
233
obj. free ( ) ;
234
234
}
235
235
236
- fn test_freed_nodes ( free_broadcaster_first : bool ) {
236
+ fn test_freed_nodes_handles ( free_broadcaster_first : bool ) {
237
237
let broadcaster = SignalDisc :: new_alloc ( ) ;
238
238
let receiver = SignalDisc :: new_alloc ( ) ;
239
239
@@ -251,21 +251,13 @@ fn test_freed_nodes(free_broadcaster_first: bool) {
251
251
} ;
252
252
253
253
// Free one of the nodes, and check if the handle thinks the objects are connected.
254
- // If the broadcaster is freed, its signals to other objects is implicitly freed as well. Thus, the handle should not be connected.
255
- // If the receiver is freed, the connection between the valid broadcaster and the non-valid freed object still exists.
256
- // In the latter case, the connection can - and probably should - be freed with disconnect().
254
+ // In both cases godot runtime should handle disconnecting the signals.
257
255
to_free. free ( ) ;
258
- let is_connected = handle. is_connected ( ) ;
259
- assert_ne ! (
260
- free_broadcaster_first, is_connected,
261
- "Handle should only return false if broadcasting is freed!"
262
- ) ;
263
-
264
- // It should be possible to disconnect a connection between a valid broadcaster and a non-valid receiver.
265
- // If the connection is not valid (e.g. because of freed broadcaster), calling disconnect() should panic.
266
- if is_connected {
267
- handle. disconnect ( ) ;
268
- } else {
256
+ assert ! ( !handle. is_connected( ) ) ;
257
+
258
+ // Calling disconnect() on already disconnected handle should panic in the Debug mode.
259
+ // Otherwise, in release mode, the error will happen in Godot runtime.
260
+ if cfg ! ( debug_assertions) {
269
261
expect_panic ( "Disconnected invalid handle!" , || {
270
262
handle. disconnect ( ) ;
271
263
} ) ;
0 commit comments