Skip to content

Commit

Permalink
Re #5366. Minor re-jig now we can create a listener w/o connecting.
Browse files Browse the repository at this point in the history
This has removed the possibility that the method will throw because
the listener cannot connect.
  • Loading branch information
RussellTaylor committed Feb 11, 2013
1 parent c091e9a commit e8f7629
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Code/Mantid/MantidQt/CustomDialogs/src/StartLiveDataDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,9 @@ void StartLiveDataDialog::setDefaultAccumulationMethod(const QString& inst)
int addIndex = ui.cmbAccumulationMethod->findText("Add");
ui.cmbAccumulationMethod->setItemData(addIndex, QVariant(Qt::ItemIsSelectable | Qt::ItemIsEnabled), Qt::UserRole - 1);

Mantid::Kernel::InstrumentInfo instrument = Mantid::Kernel::ConfigService::Instance().getInstrument(inst.toStdString());
std::string listenerName = instrument.liveListener();
// Two checks here. The first is just based on the name of the listener, the second is in
// principle more robust, but will throw if the listener can't connect (not that you'll
// get very far in that case anyway).
if ( listenerName.find("Histo") != std::string::npos
|| !Mantid::API::LiveListenerFactory::Instance().create(instrument.name(),false)->buffersEvents() )
// Check whether this listener will give back events. If not, disable 'Add' as an option
// The 'false' 2nd argument means don't connect the created listener
if ( ! Mantid::API::LiveListenerFactory::Instance().create(inst.toStdString(),false)->buffersEvents() )
{
// If 'Add' is currently selected, select 'Replace' instead
if ( ui.cmbAccumulationMethod->currentIndex() == addIndex )
Expand All @@ -332,10 +328,6 @@ void StartLiveDataDialog::setDefaultAccumulationMethod(const QString& inst)
catch( Mantid::Kernel::Exception::NotFoundError& )
{
}
// The LiveListenerFactory create() method will throw if it can't connect
catch( std::runtime_error& )
{
}
}

}
Expand Down

0 comments on commit e8f7629

Please sign in to comment.