From 7bec4bd93cbd85f544be8d4e9131b8b077e69db3 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 18 Feb 2021 22:11:25 -0500 Subject: [PATCH] Destroy system and plugin subsystems properly so they can be re-initialized. --- src/plugin.cpp | 3 +-- src/plugin/Plugin.cpp | 3 ++- src/system.cpp | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/plugin.cpp b/src/plugin.cpp index e0bfaa81..0bcfb7c9 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -208,8 +208,7 @@ static void extractPackages(std::string path) { void init() { // Don't re-initialize - if (!plugins.empty()) - return; + assert(plugins.empty()); // Load Core loadPlugin(""); diff --git a/src/plugin/Plugin.cpp b/src/plugin/Plugin.cpp index 8bd60256..87be7bb5 100644 --- a/src/plugin/Plugin.cpp +++ b/src/plugin/Plugin.cpp @@ -11,7 +11,8 @@ namespace plugin { Plugin::~Plugin() { for (Model* model : models) { - delete model; + model->plugin = NULL; + // Don't delete model because it's allocated once and referenced by a global. } } diff --git a/src/system.cpp b/src/system.cpp index 67054ad6..1d299e91 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -539,7 +539,6 @@ std::string getStackTrace() { static void initTime() { #if defined ARCH_WIN - assert(startCounter == 0); LARGE_INTEGER counter; QueryPerformanceCounter(&counter); startCounter = counter.QuadPart; @@ -549,13 +548,11 @@ static void initTime() { counterTime = 1.0 / frequency.QuadPart; #endif #if defined ARCH_LIN - assert(startTime == 0); struct timespec ts; clock_gettime(CLOCK_MONOTONIC_RAW, &ts); startTime = int64_t(ts.tv_sec) * 1000000000LL + ts.tv_nsec; #endif #if defined ARCH_MAC - assert(startTime == 0); clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);