File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -2919,20 +2919,21 @@ bool QgisApp::openLayer(const QString & fileName)
2919
2919
{
2920
2920
QFileInfo fileInfo (fileName);
2921
2921
// try to load it as raster
2922
- bool ok = addRasterLayer (fileInfo, false );
2922
+ bool ok = false ;
2923
+ CPLPushErrorHandler (CPLQuietErrorHandler);
2924
+ if (QgsRasterLayer::isValidRasterFileName (fileName))
2925
+ ok = addRasterLayer (fileInfo, false );
2926
+ else // nope - try to load it as a shape/ogr
2927
+ ok = addLayer (fileInfo);
2928
+ CPLPopErrorHandler ();
2929
+
2923
2930
if (!ok)
2924
2931
{
2925
- // nope - try to load it as a shape/ogr
2926
- ok = addLayer (fileInfo);
2927
2932
// we have no idea what this file is...
2928
- if (!ok)
2929
- {
2930
- std::cout << " Unable to load " << fileName.toLocal8Bit ().data () << std::endl;
2931
- }
2933
+ std::cout << " Unable to load " << fileName.toLocal8Bit ().data () << std::endl;
2932
2934
}
2933
- #ifdef WIN32
2934
- return true ;
2935
- #endif
2935
+
2936
+ return ok;
2936
2937
}
2937
2938
2938
2939
@@ -4976,6 +4977,7 @@ bool QgisApp::addRasterLayer(QFileInfo const & rasterFile, bool guiWarning)
4976
4977
+ tr (" is not a valid or recognized raster data source" ));
4977
4978
QMessageBox::critical (this , tr (" Invalid Data Source" ), msg);
4978
4979
}
4980
+ delete layer;
4979
4981
return false ;
4980
4982
}
4981
4983
else
You can’t perform that action at this time.
0 commit comments