From ba8c2da38c05783d1b128eebe92694f072164b75 Mon Sep 17 00:00:00 2001 From: jmespadero Date: Fri, 13 Dec 2019 17:10:45 +0100 Subject: [PATCH 1/2] check rastermodel not null --- src/meshlabplugins/filter_layer/filter_layer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/meshlabplugins/filter_layer/filter_layer.cpp b/src/meshlabplugins/filter_layer/filter_layer.cpp index bb2cff56b..dbcfb76c6 100644 --- a/src/meshlabplugins/filter_layer/filter_layer.cpp +++ b/src/meshlabplugins/filter_layer/filter_layer.cpp @@ -76,8 +76,8 @@ QString FilterLayerPlugin::filterName(FilterIDType filterId) const case FP_RENAME_RASTER : return QString("Rename Current Raster"); case FP_SELECTCURRENT : return QString("Change the current layer"); case FP_MESH_VISIBILITY : return QString("Change Visibility of layer(s)"); - case FP_EXPORT_CAMERAS: return QString("Export active rasters cameras to file"); - case FP_IMPORT_CAMERAS: return QString("Import cameras for active rasters from file"); + case FP_EXPORT_CAMERAS: return QString("Export active rasters cameras to file"); + case FP_IMPORT_CAMERAS: return QString("Import cameras for active rasters from file"); default : assert(0); } return NULL; @@ -100,8 +100,8 @@ QString FilterLayerPlugin::filterInfo(FilterIDType filterId) const case FP_RENAME_RASTER : return QString("Explicitly change the label shown for a given raster"); case FP_SELECTCURRENT : return QString("Change the current layer to a chosen one"); case FP_MESH_VISIBILITY : return QString("Make layer(s) visible/invisible. Useful for scripting."); - case FP_EXPORT_CAMERAS: return QString("Export active cameras to file, in the .out or Agisoft .xml formats"); - case FP_IMPORT_CAMERAS: return QString("Import cameras for active rasters from .out or Agisoft .xml formats"); + case FP_EXPORT_CAMERAS: return QString("Export active cameras to file, in the .out or Agisoft .xml formats"); + case FP_IMPORT_CAMERAS: return QString("Import cameras for active rasters from .out or Agisoft .xml formats"); default : assert(0); } return NULL; @@ -144,7 +144,7 @@ void FilterLayerPlugin::initParameterSet(QAction *action, MeshDocument &md, Rich break; case FP_RENAME_RASTER : parlst.addParam(new RichString ("newName", - rm->label(), + rm?rm->label():"", "New Label", "New Label for the raster")); break; @@ -182,7 +182,7 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam { case FP_RENAME_MESH: md.mm()->setLabel(par.getString("newName")); break; - case FP_RENAME_RASTER: md.rm()->setLabel(par.getString("newName")); break; + case FP_RENAME_RASTER: if (md.rm()) {md.rm()->setLabel(par.getString("newName"))}; break; case FP_SELECTCURRENT: md.setCurrent(par.getMesh("layer")); break; From 9daf8a6c8583ed367c82a431eb8b955c97c28f61 Mon Sep 17 00:00:00 2001 From: jmespadero Date: Fri, 13 Dec 2019 18:05:41 +0100 Subject: [PATCH 2/2] Extra cleanups --- .../filter_layer/filter_layer.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/meshlabplugins/filter_layer/filter_layer.cpp b/src/meshlabplugins/filter_layer/filter_layer.cpp index dbcfb76c6..af20a7d11 100644 --- a/src/meshlabplugins/filter_layer/filter_layer.cpp +++ b/src/meshlabplugins/filter_layer/filter_layer.cpp @@ -182,7 +182,19 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam { case FP_RENAME_MESH: md.mm()->setLabel(par.getString("newName")); break; - case FP_RENAME_RASTER: if (md.rm()) {md.rm()->setLabel(par.getString("newName"))}; break; + case FP_RENAME_RASTER: + { + if (md.rm()) + { + md.rm()->setLabel(par.getString("newName")); + } + else + { + this->errorMessage = "Error: Call to Rename Current Raster with no valid raster."; + return false; + } + + } break; case FP_SELECTCURRENT: md.setCurrent(par.getMesh("layer")); break; @@ -613,7 +625,7 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam sscanf(line, "%d %d", &num_cams, &num_points); ///// Check if the number of active rasters and cameras is the same - int active = 0; + unsigned active = 0; for (int i = 0; i < md.rasterList.size(); i++) { if (md.rasterList[i]->visible) @@ -622,8 +634,7 @@ bool FilterLayerPlugin::applyFilter(QAction *filter, MeshDocument &md, RichParam if (active != num_cams) { - this->errorMessage = "Error!"; - errorMessage = "Wait! The number of active rasters and the number of cams in the Bundler file is not the same!"; + this->errorMessage = "Wait! The number of active rasters and the number of cams in the Bundler file is not the same!"; return false; }