Commit 3deed871 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

fixed segfaulting while saving objects

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@3579 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c6a3ae63
......@@ -138,6 +138,12 @@ bool FileTriangleMeshPlugin::saveObject(int _id, QString _filename){
BaseObjectData* object;
PluginFunctions::get_object(_id,object);
if (object == 0){
emit log(LOGERR, "Unable to save " + object->path() + OpenFlipper::Options::dirSeparator() + object->name()
+ " (Could not get object)");
return false;
}
std::string filename = std::string( _filename.toUtf8() );
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
......@@ -148,18 +154,21 @@ bool FileTriangleMeshPlugin::saveObject(int _id, QString _filename){
OpenMesh::IO::Options opt = OpenMesh::IO::Options::Default;
if (saveBinary_->isChecked())
opt += OpenMesh::IO::Options::Binary;
if (saveColor_->isChecked())
opt += OpenMesh::IO::Options::VertexColor;
if (saveNormals_->isChecked())
opt += OpenMesh::IO::Options::VertexNormal;
if (saveTexCoords_->isChecked())
opt += OpenMesh::IO::Options::VertexTexCoord;
if ( !OpenFlipper::Options::savingSettings() && saveOptions_ != 0){
if (saveBinary_->isChecked())
opt += OpenMesh::IO::Options::Binary;
if (saveColor_->isChecked())
opt += OpenMesh::IO::Options::VertexColor;
if (saveNormals_->isChecked())
opt += OpenMesh::IO::Options::VertexNormal;
if (saveTexCoords_->isChecked())
opt += OpenMesh::IO::Options::VertexTexCoord;
}
if (OpenMesh::IO::write_mesh(*triObj->mesh(), filename.c_str(),opt) ){
emit log(LOGINFO, "Saved object to " + object->path() + OpenFlipper::Options::dirSeparator() + object->name() );
......@@ -305,6 +314,11 @@ QWidget* FileTriangleMeshPlugin::saveOptionsWidget(QString _currentFilter) {
saveBinary_->setVisible( true );
}
saveBinary_->setChecked( Qt::Unchecked );
saveColor_->setChecked( Qt::Unchecked );
saveNormals_->setChecked( Qt::Unchecked );
saveTexCoords_->setChecked( Qt::Unchecked );
return saveOptions_;
}
......
......@@ -104,12 +104,14 @@ class FileTriangleMeshPlugin : public QObject, BaseInterface, FileInterface, Loa
private :
BaseObject* objectRoot_;
private slots:
bool saveObject(int _id, QString _filename);
public slots:
int loadObject(QString _filename);
bool saveObject(int _id, QString _filename);
int addNewTriangleMesh( );
QString version() { return QString("1.0"); };
......
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