Skip to content

Commit

Permalink
Fixed unchecked casts
Browse files Browse the repository at this point in the history
Refs #10345
  • Loading branch information
DanNixon committed Oct 13, 2014
1 parent 6d06ffa commit 44645e1
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 43 deletions.
Expand Up @@ -334,6 +334,7 @@ void CreateSampleShapeDialog::addShape(QAction *shape)
{
// Get the selected item
BinaryTreeWidgetItem *parent = getSelectedItem();
if(!parent) return;
if( parent && parent->childCount() == 2 ) return;

BinaryTreeWidgetItem *child = new BinaryTreeWidgetItem(QStringList(shape->text()));
Expand All @@ -360,6 +361,7 @@ void CreateSampleShapeDialog::addOperation(QAction *opt)
{
//Get the selected item
BinaryTreeWidgetItem *selected = getSelectedItem();
if(!selected) return;
if( selected && selected->childCount() == 2 ) return;

BinaryTreeWidgetItem *operation = new BinaryTreeWidgetItem;
Expand Down Expand Up @@ -468,6 +470,7 @@ void CreateSampleShapeDialog::setupDetailsBox()
if( m_uiForm.details_scroll->widget() ) m_uiForm.details_scroll->takeWidget();

BinaryTreeWidgetItem *item = dynamic_cast<BinaryTreeWidgetItem*>(selection[0]);
if(!item) return;
QString shapename = item->text(0);
if( m_setup_map.contains(shapename) )
{
Expand All @@ -484,7 +487,6 @@ void CreateSampleShapeDialog::setupDetailsBox()
//Set it as the currently displayed widget
m_uiForm.details_scroll->setWidget(obj);
}

}

/**
Expand Down
10 changes: 1 addition & 9 deletions Code/Mantid/MantidQt/CustomInterfaces/src/ConvFit.cpp
Expand Up @@ -894,15 +894,7 @@ namespace IDA
{
// Two Lorentz
QString pref = prefBase;

if ( usingCompositeFunc )
{
pref += "f" + QString::number(funcIndex) + ".f" + QString::number(subIndex) + ".";
}
else
{
pref += "f" + QString::number(subIndex) + ".";
}
pref += "f" + QString::number(funcIndex) + ".f" + QString::number(subIndex) + ".";

m_cfDblMng->setValue(m_cfProp["Lorentzian 2.Amplitude"], parameters[pref+"Amplitude"]);
m_cfDblMng->setValue(m_cfProp["Lorentzian 2.PeakCentre"], parameters[pref+"PeakCentre"]);
Expand Down
Expand Up @@ -314,7 +314,10 @@ void IndirectDataReduction::openDirectoryDialog()
*/
void IndirectDataReduction::setIDFValues(const QString & prefix)
{
dynamic_cast<IndirectConvertToEnergy *>(m_tab_convert_to_energy)->setIDFValues(prefix);
IndirectConvertToEnergy *etTab = dynamic_cast<IndirectConvertToEnergy *>(m_tab_convert_to_energy);

if(etTab)
etTab->setIDFValues(prefix);
}

/**
Expand Down
68 changes: 36 additions & 32 deletions Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp
Expand Up @@ -181,39 +181,43 @@ namespace MantidQt
for (size_t i = 0; i < ws->getNumberHistograms(); ++i)
{
auto axis = dynamic_cast<Mantid::API::TextAxis*>(ws->getAxis(1));
std::string title = axis->label(i);

//check if the axis labels indicate this spectrum is width data
size_t qLinesWidthIndex = title.find(".Width");
size_t convFitWidthIndex = title.find(".FWHM");

bool qLinesWidth = qLinesWidthIndex != std::string::npos;
bool convFitWidth = convFitWidthIndex != std::string::npos;

//if we get a match, add this spectrum to the combobox
if(convFitWidth || qLinesWidth)
{
std::string cbItemName = "";
size_t substrIndex = 0;

if (qLinesWidth)
{
substrIndex = qLinesWidthIndex;
}
else if (convFitWidth)
{
substrIndex = convFitWidthIndex;
}

cbItemName = title.substr(0, substrIndex);
spectraList[cbItemName] = static_cast<int>(i);
m_uiForm.cbWidth->addItem(QString(cbItemName.c_str()));

//display widths f1.f1, f2.f1 and f2.f2
if (m_uiForm.cbWidth->count() == 3)
{
return;
}
if(axis)
{
std::string title = axis->label(i);

//check if the axis labels indicate this spectrum is width data
size_t qLinesWidthIndex = title.find(".Width");
size_t convFitWidthIndex = title.find(".FWHM");

bool qLinesWidth = qLinesWidthIndex != std::string::npos;
bool convFitWidth = convFitWidthIndex != std::string::npos;

//if we get a match, add this spectrum to the combobox
if(convFitWidth || qLinesWidth)
{
std::string cbItemName = "";
size_t substrIndex = 0;

if (qLinesWidth)
{
substrIndex = qLinesWidthIndex;
}
else if (convFitWidth)
{
substrIndex = convFitWidthIndex;
}

cbItemName = title.substr(0, substrIndex);
spectraList[cbItemName] = static_cast<int>(i);
m_uiForm.cbWidth->addItem(QString(cbItemName.c_str()));

//display widths f1.f1, f2.f1 and f2.f2
if (m_uiForm.cbWidth->count() == 3)
{
return;
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/MantidQt/SpectrumViewer/src/SVConnections.cpp
Expand Up @@ -313,6 +313,7 @@ bool SVConnections::eventFilter(QObject *object, QEvent *event)
int newY = m_picker_y;

QKeyEvent *keyEvent = dynamic_cast<QKeyEvent *>(event);
if(!keyEvent) return false;
int key = keyEvent->key();
switch (key)
{
Expand Down

0 comments on commit 44645e1

Please sign in to comment.