You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: godot-core/src/obj/bounds.rs
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -221,7 +221,9 @@ impl DynMemory for MemRefCounted {
221
221
}
222
222
obj.with_ref_counted(|refc| {
223
223
let success = refc.init_ref();
224
-
assert!(success,"init_ref() failed");
224
+
if !success {
225
+
crate::godot_error!("init_ref() failed, make sure you don't create a `Gd` pointer to base/self in predelete or drop()");
226
+
};
225
227
});
226
228
227
229
/*
@@ -249,6 +251,10 @@ impl DynMemory for MemRefCounted {
249
251
returnfalse;
250
252
}
251
253
obj.with_ref_counted(|refc| {
254
+
if refc.get_reference_count() == 0{
255
+
crate::godot_error!("Trying to unreference a RefCounted whose reference count is already zero, make sure you don't create a `Gd` pointer to base/self in predelete or drop()");
"Object is released during {class_name}::init(). For RefCounted, make sure you don't create a `Gd` pointer to base/self in init(). For Object, make sure you don't call `Gd.free()` in init()"
161
+
);
162
+
instance
163
+
}),
164
+
)?;
152
165
153
166
// Print shouldn't be necessary as panic itself is printed. If this changes, re-enable in error case:
154
167
// godot_error!("failed to create instance of {class_name}; Rust init() panicked");
0 commit comments