diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainViewPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainViewPresenter.cpp index 941d80ed78e36a554c8e54b80a119cdfc5c179f3..6dd6052ecec74de4f95b2329e86ca2235262c391 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainViewPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainViewPresenter.cpp @@ -1452,13 +1452,27 @@ void ReflMainViewPresenter::search() { // This is breaking the abstraction provided by IReflSearcher, but provides a // nice usability win // If we're not logged into a catalog, prompt the user to do so - if (CatalogManager::Instance().getActiveSessions().empty()) - m_view->showAlgorithmDialog("CatalogLogin"); - - auto sessionId = - CatalogManager::Instance().getActiveSessions().front()->getSessionId(); - - // try { + if (CatalogManager::Instance().getActiveSessions().empty()) { + try { + m_view->showAlgorithmDialog("CatalogLogin"); + } catch (std::runtime_error &e) { + m_view->giveUserCritical("Error Logging in:\n" + std::string(e.what()), + "login failed"); + } + } + std::string sessionId; + // check to see if we have any active sessions for ICAT + if (!CatalogManager::Instance().getActiveSessions().empty()) { + // we have an active session, so grab the ID + sessionId = + CatalogManager::Instance().getActiveSessions().front()->getSessionId(); + } else { + // there are no active sessions, we return here to avoid an exception + m_view->giveUserInfo( + "Error Logging in: Please press 'Search' to try again.", + "Login Failed"); + return; + } auto algSearch = AlgorithmManager::Instance().create("CatalogGetDataFiles"); algSearch->initialize(); algSearch->setChild(true); @@ -1468,34 +1482,6 @@ void ReflMainViewPresenter::search() { algSearch->setProperty("OutputWorkspace", "_ReflSearchResults"); auto algRunner = m_view->getAlgorithmRunner(); algRunner->startAlgorithm(algSearch); - /* - while (!currentAlg->isExecuted()) - { - - THIS WORKS FUNCTIONALLY BUT YOU NEED TO - FIND A BETTER WAY TO SEE IF ALGORITHM - HAS BEEN EXECUTED AS THIS STILL INTRODUCES - A SERIAL-TYPE LAG - - - - } - if (currentAlg->isExecuted()) - { - ITableWorkspace_sptr results = currentAlg->getProperty("OutputWorkspace"); - m_searchModel = ReflSearchModel_sptr( - new ReflSearchModel(*getTransferStrategy(), results, searchInstr)); - m_view->showSearch(m_searchModel); - } - //ITableWorkspace_sptr results = algSearch->getProperty("OutputWorkspace"); - //auto results = m_searcher->search(searchString); - m_searchModel = ReflSearchModel_sptr( - new ReflSearchModel(*getTransferStrategy(), results, searchInstr)); - m_view->showSearch(m_searchModel); - } catch (std::runtime_error &e) { - m_view->giveUserCritical("Error running search:\n" + std::string(e.what()), - "Search Failed"); - }*/ } void ReflMainViewPresenter::populateSearch(IAlgorithm_sptr searchAlg) {