Skip to content

Commit

Permalink
Remove the algorithm from the manager on a reject call...
Browse files Browse the repository at this point in the history
but only if we were supposed to execute on accept. If we are executing
on accept then we are assuming that the AlgorithmManager owns the
algorithm pointer as it must survive after the dialog is destroyed.
Refs #9756
  • Loading branch information
martyngigg committed Jun 30, 2014
1 parent dacfef1 commit 470d0c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Code/Mantid/MantidQt/API/inc/MantidQtAPI/AlgorithmDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ protected slots:

/// Executes the algorithm in a separate thread
virtual void executeAlgorithmAsync();
/// Removes the algorithm from the manager.
virtual void removeAlgorithmFromManager();

protected:

Expand Down
26 changes: 21 additions & 5 deletions Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Includes
//----------------------------------
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/IAlgorithm.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/IWorkspaceProperty.h"
#include "MantidAPI/MultipleFileProperty.h"
#include "MantidKernel/DateAndTime.h"
Expand Down Expand Up @@ -734,8 +733,8 @@ void AlgorithmDialog::accept()
}
}


//-------------------------------------------------------------------------------------------------

/**
* A slot to handle the help button click
*/
Expand Down Expand Up @@ -766,6 +765,15 @@ void AlgorithmDialog::executeAlgorithmAsync()
}
}

//-------------------------------------------------------------------------------------------------
/*
*/
void AlgorithmDialog::removeAlgorithmFromManager()
{
using namespace Mantid::API;
AlgorithmManager::Instance().removeById(m_algorithm->getAlgorithmID());
}

//------------------------------------------------------
// Private member functions
//------------------------------------------------------
Expand Down Expand Up @@ -856,8 +864,16 @@ void AlgorithmDialog::isForScript(bool forScript)
*/
void AlgorithmDialog::executeOnAccept(bool on)
{
if(on) connect(this, SIGNAL(accepted()), this, SLOT(executeAlgorithmAsync()));
else disconnect(this, SIGNAL(accepted()), this, SLOT(executeAlgorithmAsync()));
if(on)
{
connect(this, SIGNAL(accepted()), this, SLOT(executeAlgorithmAsync()));
connect(this, SIGNAL(rejected()), this, SLOT(removeAlgorithmFromManager()));
}
else
{
disconnect(this, SIGNAL(accepted()), this, SLOT(executeAlgorithmAsync()));
disconnect(this, SIGNAL(rejected()), this, SLOT(removeAlgorithmFromManager()));
}
}

//-------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 470d0c9

Please sign in to comment.