Skip to content

Commit

Permalink
Re #5496. Disconnect the recorder after it finishes
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Jul 12, 2012
1 parent 1713814 commit fa5c42b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ class MANTID_API_DLL AlgorithmObserver
alg->removeObserver(m_errorObserver);
}

/**
* Disconnect from the algorithm manager.
*/
void stopObservingManager()
{
AlgorithmManager::Instance().notificationCenter.removeObserver(m_startingObserver);
}

/// @cond Doxygen cannot handle the macro around the argument name

/** Handler of the progress notifications. Must be overriden in inherited classes.
Expand Down
12 changes: 3 additions & 9 deletions Code/Mantid/Framework/Algorithms/src/RecordPythonScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,16 @@ void RecordPythonScript::exec()
file << m_generatedScript;
file.flush();
file.close();

stopObservingManager();
}

/** Handler of the start notifications. Adds an algorithm call to the script.
* @param alg :: Shared pointer to the starting algorithm.
*/
void RecordPythonScript::startingHandle(API::IAlgorithm_sptr alg)
{
std::cerr << "Started " << alg->name() << std::endl;
auto props= alg->getProperties();
for( auto p = props.begin(); p != props.end(); ++p)
{
std::cerr << (**p).name() << '=' << (**p).value() << std::endl;
}
// Get the details of this algorithm history.
const std::string name = alg->name();
const int version = alg->version();

std::string algString;
for(auto p = props.begin() ; p != props.end(); ++p)
Expand All @@ -118,7 +112,7 @@ void RecordPythonScript::startingHandle(API::IAlgorithm_sptr alg)
}
}

m_generatedScript += name + "(" + algString + ")\n";
m_generatedScript += alg->name() + "(" + algString + ")\n";
}


Expand Down

0 comments on commit fa5c42b

Please sign in to comment.