It now reports back both kinds of errors properly. The original code simply reinitialized the error description regardless. Now it doesn't. This code is several months old and this fix may already be known about and implemented.
Will this fix will cause any problems with the rest of the code?
--Hermit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-01-07
I now see that the post "Bug (and fix)" by wasteland already addressed this issue.
Hermit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know if this is an oversight, or if it's even a problem, but when implementing:
bool success = worldXml->LoadFile();
if( !success )
{
cout << worldXml->ErrorDesc() << endl;
error = false;
}
ErrorDesc() would report back with "Failed to open file"
in both cases of fopen returning NULL, and when a parse error occurred. I changed the code:
bool TiXmlDocument::LoadFile( const char* filename )
{
...
fclose( file );
Parse( data.c_str() );
if ( !Error() )
{
return true;
}
}
SetError( TIXML_ERROR_OPENING_FILE );
return false;
...
in tinyxml.cpp to
bool TiXmlDocument::LoadFile( const char* filename )
...
fclose( file );
Parse( data.c_str() );
if ( !Error() )
{
return true;
}
else
{
return false;
}
}
else
{
SetError( TIXML_ERROR_OPENING_FILE );
return false;
}
...
It now reports back both kinds of errors properly. The original code simply reinitialized the error description regardless. Now it doesn't. This code is several months old and this fix may already be known about and implemented.
Will this fix will cause any problems with the rest of the code?
--Hermit
I now see that the post "Bug (and fix)" by wasteland already addressed this issue.
Hermit
Thanks for the fix. It's in 2.1.5 (to come)