Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in ControllerEngine::gracefulShutdown() #2767

Merged
merged 2 commits into from
May 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/controllers/controllerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void ControllerEngine::gracefulShutdown() {
// Stop all timers
stopAllTimers();

// Call each script's shutdown function if it exists
qDebug() << "Invoking shutdown() hook in scripts";
callFunctionOnObjects(m_scriptFunctionPrefixes, "shutdown");

// Prevents leaving decks in an unstable state
Expand All @@ -185,18 +185,21 @@ void ControllerEngine::gracefulShutdown() {
}
}

// Clear the cache of function wrappers
qDebug() << "Clearing function wrapper cache";
m_scriptWrappedFunctionCache.clear();

// Free all the ControlObjectScripts
QList<ConfigKey> keys = m_controlCache.keys();
QList<ConfigKey>::iterator it = keys.begin();
QList<ConfigKey>::iterator end = keys.end();
while (it != end) {
ConfigKey key = *it;
ControlObjectScript* coScript = m_controlCache.take(key);
delete coScript;
++it;
{
auto it = m_controlCache.begin();
while (it != m_controlCache.end()) {
qDebug()
<< "Deleting ControlObjectScript"
<< it.key().group
<< it.key().item;
delete it.value();
// Advance iterator
it = m_controlCache.erase(it);
}
}

delete m_pBaClass;
Expand Down