mirror of https://github.com/godotengine/godot
Core: Isolate `Ref` forward declare logic
This commit is contained in:
parent
24d74510e5
commit
e5d203f452
|
|
@ -35,10 +35,9 @@
|
|||
#include "core/os/time.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h" // For regex.
|
||||
|
||||
#ifdef MODULE_REGEX_ENABLED
|
||||
#include "modules/regex/regex.h"
|
||||
#else
|
||||
class RegEx : public RefCounted {};
|
||||
#endif // MODULE_REGEX_ENABLED
|
||||
|
||||
#if defined(MINGW_ENABLED) || defined(_MSC_VER)
|
||||
|
|
|
|||
|
|
@ -181,10 +181,15 @@ public:
|
|||
// do a lot of referencing on references and stuff
|
||||
// mutexes will avoid more crashes?
|
||||
|
||||
if (reference && reference->unreference()) {
|
||||
memdelete(reference);
|
||||
if (reference) {
|
||||
// NOTE: `reinterpret_cast` is "safe" here, as the only way to achieve a non-null
|
||||
// reference is after `ref_pointer` validates the type. This allows for passing
|
||||
// forward-declared types without cascading dependency-chains.
|
||||
if (reinterpret_cast<RefCounted *>(reference)->unreference()) {
|
||||
memdelete(reinterpret_cast<RefCounted *>(reference));
|
||||
}
|
||||
reference = nullptr;
|
||||
}
|
||||
reference = nullptr;
|
||||
}
|
||||
|
||||
template <typename... VarArgs>
|
||||
|
|
|
|||
Loading…
Reference in New Issue