Commit 76f63a04 authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Found and fixed a bug. re #1087

parent ef51610f
......@@ -137,6 +137,8 @@ public:
int functionIndexActive(int i)const;
/// Returns the name of parameter i as it declared in its function
std::string parameterLocalName(int i)const;
/// Check the function.
void checkFunction();
protected:
/// Function initialization. Declare function parameters in this method.
......
......@@ -361,6 +361,27 @@ int CompositeFunction::activeIndex(int i)const
return m_activeOffsets[iFun] + j;
}
/** Makes sure that the function is consistent.
*/
void CompositeFunction::checkFunction()
{
m_nParams = 0;
m_nActive = 0;
m_paramOffsets.clear();
m_activeOffsets.clear();
m_iFunction.clear();
m_iFunctionActive.clear();
std::vector<IFunction*> functions(m_functions.begin(),m_functions.end());
m_functions.clear();
for(int i=0;i<functions.size();i++)
{
IFunction* f = functions[i];
addFunction(f);
}
}
/** Add a function
* @param f A pointer to the added function
* @return The function index
......
......@@ -715,7 +715,8 @@ void FitPropertyBrowser::stringChanged(QtProperty* prop)
{// Check if it is a function attribute
for(int fi=0;fi<m_functionItems.size();fi++)
{
QList<QtProperty*> funProps = m_functionItems[fi]->property()->subProperties();
QtProperty* fnProp = m_functionItems[fi]->property();
QList<QtProperty*> funProps = fnProp->subProperties();
// If a string is found in funProps - it is an attribute
int ia = funProps.indexOf(prop);
if (ia >= 0)
......@@ -730,8 +731,9 @@ void FitPropertyBrowser::stringChanged(QtProperty* prop)
{
break;
}
Mantid::API::IFunction* f_new = Mantid::API::FunctionFactory::Instance().createInitialized(*function(fi));
replaceFunction(fi,f_new);
m_compositeFunction->checkFunction();
removeFunProperties(fnProp);
addFunProperties(function(fi),fnProp);
break;
}
}
......
Supports Markdown
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