Commit 11cba9cc authored by Jan Möbius's avatar Jan Möbius

Fixed crash when trying to save object via script with an id that does not exist.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20178 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 78d20a62
......@@ -1985,8 +1985,10 @@ int FileOBJPlugin::loadObject(QString _filename, DataType _type){
bool FileOBJPlugin::saveObject(int _id, QString _filename)
{
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
if ( !PluginFunctions::getObject(_id,object) ) {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
//open output stream
std::string filename = std::string( _filename.toUtf8() );
......
......@@ -1231,7 +1231,10 @@ int FileOFFPlugin::loadObject(QString _filename, DataType _type) {
bool FileOFFPlugin::saveObject(int _id, QString _filename)
{
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
if ( !PluginFunctions::getObject(_id,object) ) {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
std::string filename = std::string( _filename.toUtf8() );
......
......@@ -447,7 +447,10 @@ void FileOMPlugin::backupTextureCoordinates(MeshT& _mesh) {
bool FileOMPlugin::saveObject(int _id, QString _filename)
{
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
if ( !PluginFunctions::getObject(_id,object) ) {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
std::string filename = std::string( _filename.toUtf8() );
......
......@@ -244,19 +244,29 @@ bool FileOpenVolumeMeshPlugin::saveObject(int _id, QString _filename) {
obj->setFromFileName(_filename);
obj->setName(obj->filename());
if(!fileManager_.writeFile(_filename.toStdString(), *(mesh_obj->mesh())))
if(!fileManager_.writeFile(_filename.toStdString(), *(mesh_obj->mesh()))) {
emit log(LOGERR, tr("Unable to save ") + _filename);
return false;
}
}
else if (hex_mesh_obj) {
obj->setFromFileName(_filename);
obj->setName(obj->filename());
if (!fileManager_.writeFile(_filename.toStdString(), *(hex_mesh_obj->mesh())))
if (!fileManager_.writeFile(_filename.toStdString(), *(hex_mesh_obj->mesh()))) {
emit log(LOGERR, tr("Unable to save ") + _filename);
return false;
}
}
return true;
} else {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
return true;
}
//----------------------------------------------------------------------------
......
......@@ -630,7 +630,10 @@ int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader& _heade
bool FilePLYPlugin::saveObject(int _id, QString _filename)
{
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
if ( !PluginFunctions::getObject(_id,object) ) {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
object->setFromFileName(_filename);
object->setName(object->filename());
......
......@@ -77,7 +77,7 @@
// constants of color range drop down box
static const int COLORRANGE_0_1 = 0;
static const int COLORRANGE_0_255 = 1;
//static const int COLORRANGE_0_255 = 1;
//== IMPLEMENTATION ==============================================
......
......@@ -155,6 +155,9 @@ bool FilePlaPlugin::saveObject(int _id, QString _filename)
settings.setValue("YDirection2", plane->planeNode()->yDirection()[2]);
settings.endGroup();
}
} else {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
return true;
......
......@@ -121,7 +121,13 @@ bool FilePolyLinePlugin::saveObject(int _id, QString _filename)
PolyLineObjectSerializer serializer(pol);
serializer.serialize(fout);
fout.close();
return true;
} else {
return false;
}
} else {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
return true;
......
......@@ -338,6 +338,9 @@ bool FileSKLPlugin::saveObject(int _id, QString _filename)
obj->setName(obj->filename());
SaveSkeleton(skel->skeleton(), _filename);
}
} else {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
return true;
......
......@@ -186,6 +186,9 @@ bool FileSPHPlugin::saveObject(int _id, QString _filename)
obj->setFromFileName(_filename);
obj->setName(obj->filename());
}
} else {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
return true;
......
......@@ -172,7 +172,10 @@ int FileSTLPlugin::loadObject(QString _filename) {
bool FileSTLPlugin::saveObject(int _id, QString _filename)
{
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
if ( !PluginFunctions::getObject(_id,object) ) {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
std::string filename = std::string( _filename.toUtf8() );
......
......@@ -2659,7 +2659,10 @@ int FileVTKPlugin::loadObject(QString _filename, DataType _type){
bool FileVTKPlugin::saveObject(int _id, QString _filename) {
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
if ( !PluginFunctions::getObject(_id,object) ) {
emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
return false;
}
std::string filename = std::string( _filename.toUtf8() );
......
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