summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrune-scape <allie.smith.epic@gmail.com>2023-12-31 02:50:39 -0800
committerrune-scape <allie.smith.epic@gmail.com>2024-02-11 14:39:20 -0800
commitc5bcc3ae867923ddf16d186e4e03038a6237d76a (patch)
tree703995d06879fe47aa84d71821be5ec0f47fdbdb
parent5034478611697358f4e135c69f364ef6d8cd54dc (diff)
downloadredot-engine-c5bcc3ae867923ddf16d186e4e03038a6237d76a.tar.gz
Manage time singleton
-rw-r--r--core/os/time.cpp3
-rw-r--r--core/register_core_types.cpp3
-rw-r--r--main/main.cpp8
3 files changed, 3 insertions, 11 deletions
diff --git a/core/os/time.cpp b/core/os/time.cpp
index bad5cc2e4f..7068935d36 100644
--- a/core/os/time.cpp
+++ b/core/os/time.cpp
@@ -189,9 +189,6 @@ static const uint8_t MONTH_DAYS_TABLE[2][12] = {
Time *Time::singleton = nullptr;
Time *Time::get_singleton() {
- if (!singleton) {
- memnew(Time);
- }
return singleton;
}
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 82b3d27942..4c1ed8a69a 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -102,6 +102,7 @@ static core_bind::Marshalls *_marshalls = nullptr;
static core_bind::EngineDebugger *_engine_debugger = nullptr;
static IP *ip = nullptr;
+static Time *_time = nullptr;
static core_bind::Geometry2D *_geometry_2d = nullptr;
static core_bind::Geometry3D *_geometry_3d = nullptr;
@@ -128,6 +129,7 @@ void register_core_types() {
ObjectDB::setup();
StringName::setup();
+ _time = memnew(Time);
ResourceLoader::initialize();
register_global_constants();
@@ -436,6 +438,7 @@ void unregister_core_types() {
ResourceLoader::finalize();
ClassDB::cleanup_defaults();
+ memdelete(_time);
ObjectDB::cleanup();
Variant::unregister_types();
diff --git a/main/main.cpp b/main/main.cpp
index 49cb1ca24d..58f41fa644 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -132,7 +132,6 @@ static InputMap *input_map = nullptr;
static TranslationServer *translation_server = nullptr;
static Performance *performance = nullptr;
static PackedData *packed_data = nullptr;
-static Time *time_singleton = nullptr;
#ifdef MINIZIP_ENABLED
static ZipArchive *zip_packed_data = nullptr;
#endif
@@ -783,7 +782,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
MAIN_PRINT("Main: Initialize Globals");
input_map = memnew(InputMap);
- time_singleton = memnew(Time);
globals = memnew(ProjectSettings);
register_core_settings(); //here globals are present
@@ -2289,9 +2287,6 @@ error:
if (input_map) {
memdelete(input_map);
}
- if (time_singleton) {
- memdelete(time_singleton);
- }
if (translation_server) {
memdelete(translation_server);
}
@@ -4030,9 +4025,6 @@ void Main::cleanup(bool p_force) {
if (input_map) {
memdelete(input_map);
}
- if (time_singleton) {
- memdelete(time_singleton);
- }
if (translation_server) {
memdelete(translation_server);
}