Remove try/catch in RID. Updated docs
This commit is contained in:
parent
77fea553de
commit
7778b7459a
13
core/rid.h
13
core/rid.h
|
@ -78,16 +78,7 @@ public:
|
|||
}
|
||||
_FORCE_INLINE_ bool is_valid() const { return _data != nullptr; }
|
||||
|
||||
_FORCE_INLINE_ uint32_t get_id() const {
|
||||
if (_data) {
|
||||
try {
|
||||
return _data->get_id();
|
||||
} catch (...) {
|
||||
ERR_FAIL_V_MSG(0, "RID points to memory that has already been freed.");
|
||||
}
|
||||
}
|
||||
return 0; // An invalid or uninitialized state
|
||||
}
|
||||
_FORCE_INLINE_ uint32_t get_id() const { return _data ? _data->get_id() : 0; }
|
||||
|
||||
_FORCE_INLINE_ RID() {
|
||||
_data = nullptr;
|
||||
|
@ -156,7 +147,7 @@ public:
|
|||
}
|
||||
|
||||
void get_owned_list(List<RID> *p_owned) {
|
||||
// Used to be a debug only function disabled during release mode. Now deprecated.
|
||||
// Used to be a debug only function disabled during release mode. Now deprecated.
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -634,8 +634,8 @@
|
|||
[code]
|
||||
var r:RID = PhysicsServer.space_create()
|
||||
PhysicsServer.free_rid(r)
|
||||
print("ID: ", r.get_id()) # Not safe to access or free an invalid RID
|
||||
r = RID() # Reset RID, safe to use or free again
|
||||
print("ID: ", r.get_id()) # It is not safe to access or free an invalid RID
|
||||
r = RID() # Reset the RID so it's safe to use or free again
|
||||
print("ID: ", r.get_id())
|
||||
|
||||
Output:
|
||||
|
|
|
@ -966,8 +966,8 @@
|
|||
[code]
|
||||
var r:RID = VisualServer.get_test_cube()
|
||||
VisualServer.free_rid(r)
|
||||
print("ID: ", r.get_id()) # Not safe to access or free an invalid RID
|
||||
r = RID() # Reset RID, safe to use or free again
|
||||
print("ID: ", r.get_id()) # It is not safe to access or free an invalid RID
|
||||
r = RID() # Reset the RID so it's safe to use or free again
|
||||
print("ID: ", r.get_id())
|
||||
|
||||
Output:
|
||||
|
|
Loading…
Reference in a new issue