From adeb6b391e983e4f6e9a2d4d141e9dcd430d3e23 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 5 Dec 2019 16:29:11 +0100 Subject: [PATCH 1/2] add error message when zlib version is < 1.2.9, it is not possible to save an image as .inr, it has to be .inr.gz no matter if zlib is available or not this commit adds an error message to help the user understand the error --- CGAL_ImageIO/include/CGAL/ImageIO_impl.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CGAL_ImageIO/include/CGAL/ImageIO_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO_impl.h index 34796f5a5b6..6af56cb0ed5 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO_impl.h @@ -497,14 +497,19 @@ void _openWriteImage(_image* im, const char *name) #endif im->openMode = OM_GZ; } -#if CGAL_USE_GZFWRITE - else + else { +#if CGAL_USE_GZFWRITE im->fd = (_ImageIO_file) gzopen(name, "wb"); im->openMode = OM_FILE; - } -#endif// CGAL_USE_GZFWRITE #else + fprintf(stderr, "_openWriteImage: error: zlib version 1.2.9 or later\n" + "is required to save in non-compressed files\n"); + return; +#endif// CGAL_USE_GZFWRITE + } + +#else //CGAL_USE_ZLIB { im->fd = (_ImageIO_file) fopen(name, "wb"); im->openMode = OM_FILE; From 08b3360095678e1e41280dd53cc729e343cf3093 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 5 Dec 2019 16:31:33 +0100 Subject: [PATCH 2/2] do not pop_front() too early when "write" failed, using pop_front() prevents from using front() to the get info about what saving process has failed. Once we do not need to use front() anymore, do pop_front() --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 3 +++ Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 9fb344a24b3..0259c173e12 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -2130,10 +2130,13 @@ void MainWindow::save(QString filename, QList& to_save } } if(!saved) + { QMessageBox::warning(this, tr("Cannot save"), tr("The selected object %1 was not saved. (Maybe a wrong extension ?)") .arg(to_save.front()->name())); + to_save.pop_front(); + } } void MainWindow::on_actionSaveSnapshot_triggered() diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index 0bf1193c35b..08d5b1eee01 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -292,7 +292,8 @@ public: point_image p_im = *im_item->image()->image(); bool ok = _writeImage(&p_im, fileinfo.filePath().toUtf8()) == 0; - items.pop_front(); + if(ok) + items.pop_front(); return ok; } QString name() const override{ return "segmented images"; }