Unverified Commit 0bc884fc authored by DannyHindson's avatar DannyHindson Committed by GitHub
Browse files

Merge pull request #32531 from DavidFair/cppcheck_cache

Cppcheck cache
parents 3ee31c71 30f7d72e
......@@ -23,9 +23,9 @@ const std::string CURVES = "Curves";
using namespace Mantid::API;
namespace MantidQt::CustomInterfaces {
ALFCustomInstrumentModel::ALFCustomInstrumentModel() : m_numberOfTubesInAverage(0) {
m_base = new MantidWidgets::BaseCustomInstrumentModel("ALF_tmp", "ALF", "ALFData");
}
ALFCustomInstrumentModel::ALFCustomInstrumentModel()
: m_numberOfTubesInAverage(0),
m_base(std::make_unique<MantidWidgets::BaseCustomInstrumentModel>("ALF_tmp", "ALF", "ALFData")) {}
/*
* Runs load data alg
......
......@@ -12,6 +12,7 @@
#include "MantidQtWidgets/InstrumentView/BaseCustomInstrumentModel.h"
#include <map>
#include <memory>
#include <string>
namespace MantidQt {
......@@ -40,7 +41,7 @@ class DLLExport ALFCustomInstrumentModel : public IALFCustomInstrumentModel {
public:
ALFCustomInstrumentModel();
virtual ~ALFCustomInstrumentModel(){};
virtual ~ALFCustomInstrumentModel() = default;
// virtual so we can patch them later
virtual void loadAlg(const std::string &name) override;
virtual void transformData() override;
......@@ -69,7 +70,7 @@ public:
private:
int m_numberOfTubesInAverage;
MantidWidgets::BaseCustomInstrumentModel *m_base;
std::unique_ptr<MantidWidgets::BaseCustomInstrumentModel> m_base;
};
} // namespace CustomInterfaces
......
......@@ -25,7 +25,7 @@ namespace ISISReflectometry {
class BatchPresenterFactory : public IBatchPresenterFactory {
public:
BatchPresenterFactory(
// cppcheck-suppress passedByValue
RunsPresenterFactory runsPresenterFactory, EventPresenterFactory eventPresenterFactory,
ExperimentPresenterFactory experimentPresenterFactory, InstrumentPresenterFactory instrumentPresenterFactory,
PreviewPresenterFactory previewPresenterFactory, SavePresenterFactory savePresenterFactory)
......
......@@ -22,7 +22,7 @@ namespace ISISReflectometry {
class ExperimentValidationErrors {
public:
explicit ExperimentValidationErrors(
// cppcheck-suppress passedByValue
LookupTableValidationError lookupTableErrors)
: m_lookupTableErrors(std::move(lookupTableErrors)) {}
......
......@@ -8,8 +8,7 @@
namespace MantidQt::CustomInterfaces::ISISReflectometry {
InvalidDefaultsError::InvalidDefaultsError( // cppcheck-suppress passedByValue
int row, std::vector<int> invalidColumns)
InvalidDefaultsError::InvalidDefaultsError(int row, std::vector<int> invalidColumns)
: m_invalidColumns(std::move(invalidColumns)), m_row(row) {}
std::vector<int> const &InvalidDefaultsError::invalidColumns() const { return m_invalidColumns; }
......
......@@ -12,7 +12,7 @@
namespace MantidQt::CustomInterfaces::ISISReflectometry {
LookupTableValidationError::LookupTableValidationError(
// cppcheck-suppress passedByValue
std::vector<InvalidDefaultsError> validationErrors, boost::optional<ThetaValuesValidationError> fullTableError)
: m_validationErrors(std::move(validationErrors)), m_fullTableError(std::move(fullTableError)) {}
......
......@@ -19,9 +19,8 @@ namespace ISISReflectometry {
class RunsPresenterFactory {
public:
RunsPresenterFactory( // cppcheck-suppress passedByValue
RunsTablePresenterFactory runsTablePresenterFactory, double thetaTolerance, std::vector<std::string> instruments,
IMessageHandler *messageHandler)
RunsPresenterFactory(RunsTablePresenterFactory runsTablePresenterFactory, double thetaTolerance,
std::vector<std::string> instruments, IMessageHandler *messageHandler)
: m_runsTablePresenterFactory(std::move(runsTablePresenterFactory)), m_thetaTolerance(std::move(thetaTolerance)),
m_instruments(std::move(instruments)), m_messageHandler(messageHandler) {}
......
......@@ -24,9 +24,9 @@ Experiment::Experiment(AnalysisMode analysisMode, ReductionType reductionType, S
bool includePartialBins, bool debug, BackgroundSubtraction backgroundSubtraction,
PolarizationCorrections polarizationCorrections, FloodCorrections floodCorrections,
TransmissionStitchOptions transmissionStitchOptions,
// cppcheck-suppress passedByValue
std::map<std::string, std::string> stitchParameters,
// cppcheck-suppress passedByValue
LookupTable lookupTable)
: m_analysisMode(analysisMode), m_reductionType(reductionType), m_summationType(summationType),
m_includePartialBins(includePartialBins), m_debug(debug), m_backgroundSubtraction(backgroundSubtraction),
......
......@@ -13,12 +13,11 @@
namespace MantidQt::CustomInterfaces::ISISReflectometry {
Group::Group( // cppcheck-suppress passedByValue
std::string name, std::vector<boost::optional<Row>> rows)
Group::Group(std::string name, std::vector<boost::optional<Row>> rows)
: m_name(std::move(name)), m_postprocessedWorkspaceName(), m_rows(std::move(rows)) {}
Group::Group(
// cppcheck-suppress passedByValue
std::string name)
: m_name(std::move(name)), m_rows() {}
......
......@@ -9,7 +9,7 @@
namespace MantidQt::CustomInterfaces::ISISReflectometry {
LookupRow::LookupRow(boost::optional<double> theta,
// cppcheck-suppress passedByValue
TransmissionRunPair transmissionRuns,
boost::optional<ProcessingInstructions> transmissionProcessingInstructions, RangeInQ qRange,
boost::optional<double> scaleFactor,
......
......@@ -32,9 +32,7 @@ int countItems(ReductionJobs const &jobs, Item::ItemCountFunction countFunction)
}
} // namespace
ReductionJobs::ReductionJobs( // cppcheck-suppress passedByValue
std::vector<Group> groups)
: m_groups(std::move(groups)), m_groupNameSuffix(1) {}
ReductionJobs::ReductionJobs(std::vector<Group> groups) : m_groups(std::move(groups)), m_groupNameSuffix(1) {}
ReductionJobs::ReductionJobs() : m_groupNameSuffix(1) {}
......
......@@ -12,9 +12,9 @@
namespace MantidQt::CustomInterfaces::ISISReflectometry {
ReductionWorkspaces::ReductionWorkspaces(
// cppcheck-suppress passedByValue
std::vector<std::string> inputRunNumbers,
// cppcheck-suppress passedByValue
TransmissionRunPair transmissionRuns)
: m_inputRunNumbers(std::move(inputRunNumbers)), m_transmissionRuns(std::move(transmissionRuns)), m_iVsLambda(),
m_iVsQ(), m_iVsQBinned() {}
......
......@@ -11,13 +11,12 @@
namespace MantidQt::CustomInterfaces::ISISReflectometry {
Row::Row( // cppcheck-suppress passedByValue
std::vector<std::string> runNumbers, double theta,
// cppcheck-suppress passedByValue
TransmissionRunPair transmissionRuns, RangeInQ qRange, boost::optional<double> scaleFactor,
ReductionOptionsMap reductionOptions,
// cppcheck-suppress passedByValue
ReductionWorkspaces reducedWorkspaceNames)
Row::Row(std::vector<std::string> runNumbers, double theta,
TransmissionRunPair transmissionRuns, RangeInQ qRange, boost::optional<double> scaleFactor,
ReductionOptionsMap reductionOptions,
ReductionWorkspaces reducedWorkspaceNames)
: Item(), m_runNumbers(std::move(runNumbers)), m_theta(theta), m_qRange(std::move(qRange)), m_qRangeOutput(),
m_scaleFactor(std::move(scaleFactor)), m_transmissionRuns(std::move(transmissionRuns)),
m_reducedWorkspaceNames(std::move(reducedWorkspaceNames)), m_reductionOptions(std::move(reductionOptions)) {
......
......@@ -11,10 +11,9 @@ namespace MantidQt::CustomInterfaces::ISISReflectometry {
using MantidWidgets::Batch::RowLocation;
RunsTable::RunsTable( // cppcheck-suppress passedByValue
std::vector<std::string> instruments, double thetaTolerance,
// cppcheck-suppress passedByValue
ReductionJobs reductionJobs)
RunsTable::RunsTable(std::vector<std::string> instruments, double thetaTolerance,
ReductionJobs reductionJobs)
: m_instruments(std::move(instruments)), m_thetaTolerance(thetaTolerance),
m_reductionJobs(std::move(reductionJobs)), m_selectedRowLocations() {}
......
......@@ -41,9 +41,7 @@ std::ostream &operator<<(std::ostream &os, UniformSlicingByNumberOfSlices const
return (os << slicing.numberOfSlices() << " even slices");
}
CustomSlicingByList::CustomSlicingByList( // cppcheck-suppress passedByValue
std::vector<double> sliceTimes)
: m_sliceTimes(std::move(sliceTimes)) {}
CustomSlicingByList::CustomSlicingByList(std::vector<double> sliceTimes) : m_sliceTimes(std::move(sliceTimes)) {}
std::vector<double> const &CustomSlicingByList::sliceTimes() const { return m_sliceTimes; }
......@@ -66,8 +64,7 @@ std::ostream &operator<<(std::ostream &os, CustomSlicingByList const &slicing) {
std::ostream &operator<<(std::ostream &os, InvalidSlicing const &) { return (os << "invalid slices"); }
SlicingByEventLog::SlicingByEventLog( // cppcheck-suppress passedByValue
std::vector<double> sliceAtValues, std::string blockValue)
SlicingByEventLog::SlicingByEventLog(std::vector<double> sliceAtValues, std::string blockValue)
: m_sliceAtValues(std::move(sliceAtValues)), m_blockName(std::move(blockValue)) {}
std::vector<double> const &SlicingByEventLog::sliceAtValues() const { return m_sliceAtValues; }
......
......@@ -11,17 +11,16 @@ namespace MantidQt::CustomInterfaces::ISISReflectometry {
TransmissionRunPair::TransmissionRunPair() : m_firstTransmissionRunNumbers(), m_secondTransmissionRunNumbers() {}
TransmissionRunPair::TransmissionRunPair( // cppcheck-suppress passedByValue
std::string firstTransmissionRun,
// cppcheck-suppress passedByValue
std::string secondTransmissionRun)
TransmissionRunPair::TransmissionRunPair(std::string firstTransmissionRun,
std::string secondTransmissionRun)
: m_firstTransmissionRunNumbers{std::move(firstTransmissionRun)}, m_secondTransmissionRunNumbers{
std::move(secondTransmissionRun)} {}
TransmissionRunPair::TransmissionRunPair(
// cppcheck-suppress passedByValue
std::vector<std::string> firstTransmissionRunNumbers,
// cppcheck-suppress passedByValue
std::vector<std::string> secondTransmissionRunNumbers)
: m_firstTransmissionRunNumbers(std::move(firstTransmissionRunNumbers)),
m_secondTransmissionRunNumbers(std::move(secondTransmissionRunNumbers)) {}
......
......@@ -11,9 +11,7 @@ namespace MantidQt::CustomInterfaces {
IndirectBayesTab::IndirectBayesTab(QWidget *parent) : IndirectTab(parent), m_propTree(new QtTreePropertyBrowser()) {
m_propTree->setFactoryForManager(m_dblManager, m_dblEdFac);
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
// cppcheck-suppress pureVirtualCall
SLOT(updateProperties(QtProperty *, double)));
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double)));
}
IndirectBayesTab::~IndirectBayesTab() { m_propTree->unsetFactoryForManager(m_dblManager); }
......
......@@ -82,6 +82,9 @@ public:
explicit WidgetScrollbarDecorator(QWidget *target);
virtual ~WidgetScrollbarDecorator();
WidgetScrollbarDecorator(const WidgetScrollbarDecorator &) = delete;
WidgetScrollbarDecorator &operator=(WidgetScrollbarDecorator) = delete;
/// Check whether the target is currently scrollable
bool enabled() const;
......
......@@ -213,7 +213,7 @@ protected:
private:
friend class ObserverCallback;
ObserverCallback *m_proxy;
std::unique_ptr<ObserverCallback> m_proxy;
bool m_predel_observed, m_postdel_observed, m_add_observed, m_repl_observed, m_rename_observed, m_clr_observed;
};
......
......@@ -48,23 +48,23 @@ WorkspaceObserver::WorkspaceObserver()
m_addObserver(*this, &WorkspaceObserver::_addHandle),
m_afterReplaceObserver(*this, &WorkspaceObserver::_afterReplaceHandle),
m_renameObserver(*this, &WorkspaceObserver::_renameHandle),
m_clearADSObserver(*this, &WorkspaceObserver::_clearADSHandle), m_predel_observed(false),
m_postdel_observed(false), m_add_observed(false), m_repl_observed(false), m_rename_observed(false),
m_clr_observed(false) {
m_proxy = new ObserverCallback(this);
}
m_clearADSObserver(*this, &WorkspaceObserver::_clearADSHandle), m_proxy(std::make_unique<ObserverCallback>(this)),
m_predel_observed(false), m_postdel_observed(false), m_add_observed(false), m_repl_observed(false),
m_rename_observed(false), m_clr_observed(false) {}
/// Destructor
WorkspaceObserver::~WorkspaceObserver() {
observePreDelete(false);
observePostDelete(false);
observeAdd(false);
observeAfterReplace(false);
observeRename(false);
observeADSClear(false);
auto &notificationCenter = Mantid::API::AnalysisDataService::Instance().notificationCenter;
// Do the minimum cleanup of dangling observer refs, rather than disconnecting signals / slots
// through observeX, as we're about to destroy the proxy anyway
notificationCenter.removeObserver(m_preDeleteObserver);
notificationCenter.removeObserver(m_postDeleteObserver);
notificationCenter.removeObserver(m_addObserver);
notificationCenter.removeObserver(m_afterReplaceObserver);
notificationCenter.removeObserver(m_renameObserver);
notificationCenter.removeObserver(m_clearADSObserver);
m_proxy->disconnect();
delete m_proxy;
}
/**
......@@ -76,13 +76,13 @@ void WorkspaceObserver::observePreDelete(bool turnOn) {
if (turnOn && !m_predel_observed) // Turning it on
{
Mantid::API::AnalysisDataService::Instance().notificationCenter.addObserver(m_preDeleteObserver);
m_proxy->connect(m_proxy, SIGNAL(preDeleteRequested(const std::string &, Mantid::API::Workspace_sptr)),
m_proxy->connect(m_proxy.get(), SIGNAL(preDeleteRequested(const std::string &, Mantid::API::Workspace_sptr)),
SLOT(handlePreDelete(const std::string &, Mantid::API::Workspace_sptr)), Qt::QueuedConnection);
} else if (!turnOn && m_predel_observed) // Turning it off
{
Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(m_preDeleteObserver);
m_proxy->disconnect(m_proxy, SIGNAL(preDeleteRequested(const std::string &, Mantid::API::Workspace_sptr)), m_proxy,
SLOT(handlePreDelete(const std::string &, Mantid::API::Workspace_sptr)));
m_proxy->disconnect(m_proxy.get(), SIGNAL(preDeleteRequested(const std::string &, Mantid::API::Workspace_sptr)),
m_proxy.get(), SLOT(handlePreDelete(const std::string &, Mantid::API::Workspace_sptr)));
} else {
}
m_predel_observed = turnOn;
......@@ -97,12 +97,12 @@ void WorkspaceObserver::observePostDelete(bool turnOn) {
if (turnOn && !m_postdel_observed) // Turning it on
{
Mantid::API::AnalysisDataService::Instance().notificationCenter.addObserver(m_postDeleteObserver);
m_proxy->connect(m_proxy, SIGNAL(postDeleteRequested(const std::string &)),
m_proxy->connect(m_proxy.get(), SIGNAL(postDeleteRequested(const std::string &)),
SLOT(handlePostDelete(const std::string &)), Qt::QueuedConnection);
} else if (!turnOn && m_postdel_observed) // Turning it off
{
Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(m_postDeleteObserver);
m_proxy->disconnect(m_proxy, SIGNAL(postDeleteRequested(const std::string &)), m_proxy,
m_proxy->disconnect(m_proxy.get(), SIGNAL(postDeleteRequested(const std::string &)), m_proxy.get(),
SLOT(handlePostDelete(const std::string &)));
} else {
}
......@@ -117,12 +117,12 @@ void WorkspaceObserver::observePostDelete(bool turnOn) {
void WorkspaceObserver::observeAfterReplace(bool turnOn) {
if (turnOn && !m_repl_observed) {
Mantid::API::AnalysisDataService::Instance().notificationCenter.addObserver(m_afterReplaceObserver);
m_proxy->connect(m_proxy, SIGNAL(afterReplaced(const std::string &, Mantid::API::Workspace_sptr)),
m_proxy->connect(m_proxy.get(), SIGNAL(afterReplaced(const std::string &, Mantid::API::Workspace_sptr)),
SLOT(handleAfterReplace(const std::string &, Mantid::API::Workspace_sptr)), Qt::QueuedConnection);
} else if (!turnOn && m_repl_observed) {
Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(m_afterReplaceObserver);
m_proxy->disconnect(m_proxy, SIGNAL(afterReplaced(const std::string &, Mantid::API::Workspace_sptr)), m_proxy,
SLOT(handleAfterReplace(const std::string &, Mantid::API::Workspace_sptr)));
m_proxy->disconnect(m_proxy.get(), SIGNAL(afterReplaced(const std::string &, Mantid::API::Workspace_sptr)),
m_proxy.get(), SLOT(handleAfterReplace(const std::string &, Mantid::API::Workspace_sptr)));
}
m_repl_observed = turnOn;
}
......@@ -135,11 +135,11 @@ void WorkspaceObserver::observeAfterReplace(bool turnOn) {
void WorkspaceObserver::observeRename(bool turnOn) {
if (turnOn && !m_rename_observed) {
Mantid::API::AnalysisDataService::Instance().notificationCenter.addObserver(m_renameObserver);
m_proxy->connect(m_proxy, SIGNAL(renamed(const std::string &, const std::string &)),
m_proxy->connect(m_proxy.get(), SIGNAL(renamed(const std::string &, const std::string &)),
SLOT(handleRename(const std::string &, const std::string &)), Qt::QueuedConnection);
} else if (!turnOn && m_rename_observed) {
Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(m_renameObserver);
m_proxy->disconnect(m_proxy, SIGNAL(renamed(const std::string &, const std::string &)), m_proxy,
m_proxy->disconnect(m_proxy.get(), SIGNAL(renamed(const std::string &, const std::string &)), m_proxy.get(),
SLOT(handleRename(const std::string &, const std::string &)));
}
m_rename_observed = turnOn;
......@@ -153,12 +153,12 @@ void WorkspaceObserver::observeRename(bool turnOn) {
void WorkspaceObserver::observeAdd(bool turnOn) {
if (turnOn && !m_add_observed) {
Mantid::API::AnalysisDataService::Instance().notificationCenter.addObserver(m_addObserver);
m_proxy->connect(m_proxy, SIGNAL(addRequested(const std::string &, Mantid::API::Workspace_sptr)),
m_proxy->connect(m_proxy.get(), SIGNAL(addRequested(const std::string &, Mantid::API::Workspace_sptr)),
SLOT(handleAdd(const std::string &, Mantid::API::Workspace_sptr)), Qt::QueuedConnection);
} else if (!turnOn && m_add_observed) {
Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(m_addObserver);
m_proxy->disconnect(m_proxy, SIGNAL(addRequested(const std::string &, Mantid::API::Workspace_sptr)), m_proxy,
SLOT(handleAdd(const std::string &, Mantid::API::Workspace_sptr)));
m_proxy->disconnect(m_proxy.get(), SIGNAL(addRequested(const std::string &, Mantid::API::Workspace_sptr)),
m_proxy.get(), SLOT(handleAdd(const std::string &, Mantid::API::Workspace_sptr)));
}
m_add_observed = turnOn;
}
......@@ -171,10 +171,10 @@ void WorkspaceObserver::observeAdd(bool turnOn) {
void WorkspaceObserver::observeADSClear(bool turnOn) {
if (turnOn && !m_clr_observed) {
Mantid::API::AnalysisDataService::Instance().notificationCenter.addObserver(m_clearADSObserver);
m_proxy->connect(m_proxy, SIGNAL(adsCleared()), SLOT(handleClearADS()), Qt::QueuedConnection);
m_proxy->connect(m_proxy.get(), SIGNAL(adsCleared()), SLOT(handleClearADS()), Qt::QueuedConnection);
} else if (!turnOn && m_clr_observed) {
Mantid::API::AnalysisDataService::Instance().notificationCenter.removeObserver(m_clearADSObserver);
m_proxy->disconnect(m_proxy, SIGNAL(adsCleared()), m_proxy, SLOT(handleClearADS()));
m_proxy->disconnect(m_proxy.get(), SIGNAL(adsCleared()), m_proxy.get(), SLOT(handleClearADS()));
}
m_clr_observed = turnOn;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment