mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 21:52:51 +00:00
d904d05e65
This commit addresses multiple issues with `Variant`s that point to an `Object` which is later released, when it's tried to be accessed again. Formerly, **while running on the debugger the system would check if the instance id was still valid** to print warnings or return special values. Some cases weren't being warned about whatsoever. Also, a newly allocated `Object` could happen to be allocated at the same memory address of an old one, making cases of use hard to find and having **`Variant`s pointing to the old one magically reassigned to the new**. This commit makes the engine realize all these situations **under debugging** so you can detect and fix them. Running without a debugger attached will still behave as it always did. Also the warning messages have been extended and made clearer. All that said, in the name of performance there's still one possible case of undefined behavior: in multithreaded scripts there would be a race condition between a thread freeing an `Object` and another one trying to operate on it. The latter may not realize the `Object` has been freed soon enough. But that's a case of bad scripting that was never supported anyway.
39 lines
2.3 KiB
C++
39 lines
2.3 KiB
C++
/*************************************************************************/
|
|
/* object_rc.h */
|
|
/*************************************************************************/
|
|
/* This file is part of: */
|
|
/* GODOT ENGINE */
|
|
/* https://godotengine.org */
|
|
/*************************************************************************/
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
|
/* */
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
/* a copy of this software and associated documentation files (the */
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
/* the following conditions: */
|
|
/* */
|
|
/* The above copyright notice and this permission notice shall be */
|
|
/* included in all copies or substantial portions of the Software. */
|
|
/* */
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
/*************************************************************************/
|
|
|
|
#ifndef OBJECTID_H
|
|
#define OBJECTID_H
|
|
|
|
#include "core/int_types.h"
|
|
|
|
typedef uint64_t ObjectID;
|
|
|
|
#endif
|