Skip to content

Commit

Permalink
Make Core::~Core safe to call after die
Browse files Browse the repository at this point in the history
  • Loading branch information
suokko committed Jul 10, 2018
1 parent ce6af3d commit 5eea719
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions library/Core.cpp
Expand Up @@ -1479,17 +1479,7 @@ void fIOthread(void * iodata)

Core::~Core()
{
if (MainThread::suspend().owns_lock())
MainThread::suspend().unlock();

if (d->hotkeythread.joinable()) {
std::lock_guard<std::mutex> lock(HotkeyMutex);
hotkey_set = SHUTDOWN;
HotkeyCond.notify_one();
}
if (d->iothread.joinable())
con.shutdown();
delete d;
// we leak the memory in case ~Core is called after _exit
}

Core::Core() :
Expand Down Expand Up @@ -2299,6 +2289,8 @@ int Core::Shutdown ( void )
}
allModules.clear();
memset(&(s_mods), 0, sizeof(s_mods));
delete d;
d = nullptr;
return -1;
}

Expand Down

0 comments on commit 5eea719

Please sign in to comment.