diff --git a/src/common/thread/thread.cpp b/src/common/thread/thread.cpp index b8bc1fd5..967fd80f 100644 --- a/src/common/thread/thread.cpp +++ b/src/common/thread/thread.cpp @@ -14,11 +14,17 @@ Thread::Thread(const char* label, size_t stackSize, bool detached, RunFunction r } Thread::~Thread() { - if(!detached_) join(); + if(!detached_) { + join(); + } else { +#if !defined(DC_SH4) + delete reinterpret_cast(nativeHandle_); +#endif + } } bool Thread::spawn(const char *label, size_t stackSize, bool detached, RunFunction runFunction, void* param) { -#ifdef DC_SH4 +#if defined(DC_SH4) const kthread_attr_t thdAttr = { .create_detached = detached, .stack_size = stackSize, @@ -40,10 +46,11 @@ bool Thread::join() { if(!isValid() || detached_) return false; -#ifdef DC_SH4 +#if defined(DC_SH4) if(thd_join(reinterpret_cast(nativeHandle_), nullptr) != 0) return false; #else + reinterpret_cast(nativeHandle_)->join(); delete reinterpret_cast(nativeHandle_); #endif diff --git a/src/common/vmu/vmu.h b/src/common/vmu/vmu.h index 104d2fb7..c9858085 100644 --- a/src/common/vmu/vmu.h +++ b/src/common/vmu/vmu.h @@ -62,7 +62,7 @@ protected: VmuProfiler(); // Main entry point and loop for the monitor thread - virtual void run(); + void run(); public: