MODIFIED: #1471 Forgot to remove parents' properties before saving the node properties.

This commit is contained in:
dfighter1985 2012-12-02 19:47:12 +01:00
parent 713c256c2a
commit 5f0e715df4
2 changed files with 32 additions and 1 deletions

View file

@ -37,6 +37,16 @@ namespace GUIEditor
entry.propDefault = propdefault; entry.propDefault = propdefault;
return entry; return entry;
} }
bool operator==( const SPropEntry &other ) const
{
if( ( propName == other.propName ) &&
( propType == other.propType ) &&
( propDefault == other.propDefault ) )
return true;
else
return false;
}
}; };
struct SWidgetInfo struct SWidgetInfo

View file

@ -30,6 +30,27 @@ namespace GUIEditor
std::fstream f; std::fstream f;
std::string filename = "widgets/" + node->getInfo().name + ".xml"; std::string filename = "widgets/" + node->getInfo().name + ".xml";
SWidgetInfo &info = node->getInfo(); SWidgetInfo &info = node->getInfo();
// Make a copy of the properties, then remove all the parents' properties, since we only want to save the properties of this node
std::vector< SPropEntry > props;
props.resize( info.props.size() );
std::copy( info.props.begin(), info.props.end(), props.begin() );
CWidgetInfoTreeNode *parent = node->getParent();
if( parent != NULL )
{
SWidgetInfo &parentInfo = parent->getInfo();
std::vector< SPropEntry >::const_iterator itr = parentInfo.props.begin();
while( itr != parentInfo.props.end() )
{
std::vector< SPropEntry >::const_iterator fItr;
fItr = std::find( props.begin(), props.end(), *itr );
if( fItr == props.end() )
continue;
props.erase( fItr );
++itr;
}
}
f.open( filename.c_str(), std::ios_base::out ); f.open( filename.c_str(), std::ios_base::out );
if( !f.is_open() ) if( !f.is_open() )
@ -55,7 +76,7 @@ namespace GUIEditor
f << "\t</header>" << std::endl; f << "\t</header>" << std::endl;
f << "\t<properties>" << std::endl; f << "\t<properties>" << std::endl;
for( std::vector< SPropEntry >::const_iterator itr = info.props.begin(); itr != info.props.end(); ++itr ) for( std::vector< SPropEntry >::const_iterator itr = props.begin(); itr != props.end(); ++itr )
{ {
f << "\t\t<property>" << std::endl; f << "\t\t<property>" << std::endl;