From 87321765a61d9771b740af4f3a2d3cd5e7509069 Mon Sep 17 00:00:00 2001 From: gsherman Date: Sat, 3 Aug 2002 06:37:40 +0000 Subject: [PATCH] valid layer checking added git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@85 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/qgisapp.cpp | 10 ++++++++-- src/qgsmaplayer.cpp | 3 +++ src/qgsshapefilelayer.cpp | 11 ++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/qgisapp.cpp b/src/qgisapp.cpp index 215d0d83dd1..92eabeb9ccc 100644 --- a/src/qgisapp.cpp +++ b/src/qgisapp.cpp @@ -92,8 +92,14 @@ void QgisApp::addLayer () QgsShapeFileLayer *lyr = new QgsShapeFileLayer (*it, base); // give it a random color - // add it to the mapcanvas collection - mapCanvas->addLayer (lyr); + if(lyr->isValid()){ + // add it to the mapcanvas collection + mapCanvas->addLayer (lyr); + }else{ + QString msg = *it; + msg += " is not a valid or recognized data source"; + QMessageBox::critical(this,"Invalid Data Source",msg); + } ++it; } diff --git a/src/qgsmaplayer.cpp b/src/qgsmaplayer.cpp index 56b3ee8987d..dd06a47f9b6 100644 --- a/src/qgsmaplayer.cpp +++ b/src/qgsmaplayer.cpp @@ -102,3 +102,6 @@ void QgsMapLayer::setZ (int zorder) { zpos = zorder; } +bool QgsMapLayer::isValid(){ + return valid; + } \ No newline at end of file diff --git a/src/qgsshapefilelayer.cpp b/src/qgsshapefilelayer.cpp index e7ce6f51155..19c9346b71b 100644 --- a/src/qgsshapefilelayer.cpp +++ b/src/qgsshapefilelayer.cpp @@ -44,15 +44,8 @@ QgsShapeFileLayer::QgsShapeFileLayer (QString vectorLayerPath, QString baseName) layerExtent.setXmin (ext->MinX); layerExtent.setYmax (ext->MaxY); layerExtent.setYmin (ext->MinY); -/* while(OGRFeature *fet = ogrLayer->GetNextFeature()){ - fet->DumpReadable(stdout); - OGRGeometry *geom = fet->GetGeometryRef(); - std::cout << geom->getGeometryName() << std::endl; - - delete fet; - } - */ - + }else{ + valid = false; } }