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

BugFix: Observer issue of AlgorithmProxy #11786

Closed
AntonPiccardoSelg opened this issue Jan 22, 2015 · 1 comment
Closed

BugFix: Observer issue of AlgorithmProxy #11786

AntonPiccardoSelg opened this issue Jan 22, 2015 · 1 comment
Assignees
Labels
Framework Issues and pull requests related to components in the Framework

Comments

@AntonPiccardoSelg
Copy link
Contributor

This issue was originally TRAC 10947

There are circumstances when an observer is not added to correctly to an algorithm. The bug appears when adding an NObserver to an algorithm and then opening an algorithm dialog which has been set with the same algorithm.
The input checks of the algorithm dialog remove the underlying algorithm.

'''Example code structure which triggers the bug:'''
A class A contains an NObserver

in A.h

#include "Poco/NObserver.h"
class A 
{
 public:
  A(){};
  ~A(){};
  void showDialog();

 private:

 // Callback function
  void handleAlgorithmFinishedNotification(const Poco::AutoPtr`<Mantid::API::Algorithm::FinishedNotification>`& pNf);

 // Observer
 Poco::NObserver`<A, Mantid::API::Algorithm::FinishedNotification>`  m_finishedObserver;
}


The callback itself is just

void A::handleAlgorithmFinishedNotification(const Poco::AutoPtr`<Mantid::API::Algorithm::FinishedNotification>`& pNf);
{
  //...never gets here
}

Inside the showDialog an algorithm is created and the m_finishedObserver is added to the list of observers of the algorithm. The algorithm is then added to an algorithm dialog

void A::showDialog()
{
 // Create algorithm
 Mantid::API::IAlgorithm_sptr algorithm = Mantid::API::AlgorithmManager::Instance().create("SliceMD",1);

 // Add observer
 algorithm->addObserver(m_finishedObserver);

 // Create dialog
 MantidQt::MantidWidgets::BinMDDialog* dialog = new MantidQt::MantidWidgets::BinMDDialog(this);
 dialog->setAttribute(Qt::WA_DeleteOnClose, true);
 dialog->setAlgorithm(algorithm);
 dialog->show();
 dialog->raise();
 dialog->activateWindow();
}

When the user presses accept on the algorithm dialog, the callback of class A is not executed, yet the callback of the AlgorithmMonitor is executed. The main places to look for a bug are the AlgorithmProxy. We noted that between original algorithm object was dropped between the addObserver call in the sample code and the addObserver call from within the AlgorithmMonitor.


Keywords: Algorithm Observer

@AntonPiccardoSelg AntonPiccardoSelg added the Framework Issues and pull requests related to components in the Framework label Jun 3, 2015
@AntonPiccardoSelg AntonPiccardoSelg self-assigned this Jun 3, 2015
@AntonPiccardoSelg
Copy link
Contributor Author

Does not seem to be an issue any longer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues and pull requests related to components in the Framework
Projects
None yet
Development

No branches or pull requests

1 participant