Skip to content

Commit

Permalink
Fix for #854 - Dont assert for unknown types in QgsVectorFileWriter
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7742 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Dec 7, 2007
1 parent 2bacc50 commit f07f41b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/app/legend/qgslegendlayerfile.cpp
Expand Up @@ -405,6 +405,10 @@ void QgsLegendLayerFile::saveAsShapefileGeneral(bool saveOnlySelection)
case QgsVectorFileWriter::ErrCreateLayer:
QMessageBox::warning(0, tr("Error"), tr("Layer creation failed"));
break;
case QgsVectorFileWriter::ErrAttributeTypeUnsupported:
QMessageBox::warning(0, tr("Error"),
tr("Layer attribute table contains unsupported datatype(s)"));
break;
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -122,7 +122,9 @@ QgsVectorFileWriter::QgsVectorFileWriter(const QString& shapefileName,
ogrType = OFTReal;
break;
default:
assert(0 && "invalid variant type!");
//assert(0 && "invalid variant type!");
mError = ErrAttributeTypeUnsupported;
return;
}

// create field definition
Expand Down Expand Up @@ -220,7 +222,8 @@ bool QgsVectorFileWriter::addFeature(QgsFeature& feature)
poFeature->SetField(encAttrName.data(), mCodec->fromUnicode(attrValue.toString()).data());
break;
default:
assert(0 && "invalid variant type");
//assert(0 && "invalid variant type");
return false;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsvectorfilewriter.h
Expand Up @@ -47,7 +47,8 @@ class CORE_EXPORT QgsVectorFileWriter
NoError = 0,
ErrDriverNotFound,
ErrCreateDataSource,
ErrCreateLayer
ErrCreateLayer,
ErrAttributeTypeUnsupported
};

/** Write contents of vector layer to a shapefile */
Expand Down

0 comments on commit f07f41b

Please sign in to comment.