From c817dc8c501e0dcb5ae82ab1001404c0e61cfb92 Mon Sep 17 00:00:00 2001 From: Antti Soininen <soininen@ill.fr> Date: Tue, 26 Sep 2017 10:01:36 +0200 Subject: [PATCH] MantidMatrix: remove the DX extension if there are no X errors. Re #20632 --- MantidPlot/src/Mantid/MantidMatrix.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/MantidPlot/src/Mantid/MantidMatrix.cpp b/MantidPlot/src/Mantid/MantidMatrix.cpp index b03e2047769..577746f4aa5 100644 --- a/MantidPlot/src/Mantid/MantidMatrix.cpp +++ b/MantidPlot/src/Mantid/MantidMatrix.cpp @@ -1326,11 +1326,25 @@ void MantidMatrix::setupNewExtension(MantidMatrixModel::Type type) { * @param ws: the new workspace */ void MantidMatrix::updateExtensions(Mantid::API::MatrixWorkspace_sptr ws) { - // Remove the tabs - for (auto it = m_extensions.begin(); it != m_extensions.end(); ++it) { - auto &extension = it->second; - extension.model = new MantidMatrixModel(this, ws.get(), m_rows, m_cols, - m_startRow, it->first); - connectTableView(extension.tableView, extension.model); + auto it = m_extensions.begin(); + while (it != m_extensions.cend()) { + switch (it->first) { + case MantidMatrixModel::DX: + if (ws->hasDx(0)) { + auto &extension = it->second; + extension.model = new MantidMatrixModel(this, ws.get(), m_rows, m_cols, + m_startRow, it->first); + connectTableView(extension.tableView, extension.model); + ++it; + } else { + closeDependants(); + m_tabs->removeTab(modelTypeToInt(it->first)); + delete it->second.tableView; + it = m_extensions.erase(it); + } + break; + default: + throw std::runtime_error("Unknown MantidMatrix extension."); + } } } -- GitLab