Skip to content

Commit

Permalink
Re #7843. Disconnect observers if cancelling or deleting.
Browse files Browse the repository at this point in the history
Because very bad things happen if the handlers are called after the
object they live in has been deleted!
  • Loading branch information
RussellTaylor committed Sep 5, 2013
1 parent 2322a88 commit 9f99d4e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Code/Mantid/MantidQt/API/src/AlgorithmRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ namespace API
*/
AlgorithmRunner::~AlgorithmRunner()
{
if (m_asyncAlg)
{
m_asyncAlg->removeObserver(m_finishedObserver);
m_asyncAlg->removeObserver(m_errorObserver);
m_asyncAlg->removeObserver(m_progressObserver);
}
delete m_asyncResult;
}

Expand All @@ -37,7 +43,7 @@ namespace API
*/
void AlgorithmRunner::cancelRunningAlgorithm()
{
// Cancel any currently running rebinning algorithms
// Cancel any currently running algorithms
if (m_asyncAlg)
{
if (m_asyncAlg->isRunning())
Expand All @@ -48,6 +54,9 @@ namespace API
delete m_asyncResult;
m_asyncResult = NULL;
}
m_asyncAlg->removeObserver(m_finishedObserver);
m_asyncAlg->removeObserver(m_errorObserver);
m_asyncAlg->removeObserver(m_progressObserver);
m_asyncAlg.reset();
}
}
Expand Down

0 comments on commit 9f99d4e

Please sign in to comment.