Fix warning about discarding return type of function with [[nodiscard]] (#9127)

## Summary of Changes

```
Building CXX object test/Generator_Demo/CMakeFiles/Generator_2.dir/Generator_2.cpp.o
cd /home/cgal_tester/build/src/cmake/platforms/ArchLinux-clang/test/Generator_Demo && /bin/clang++ -DCGAL_TEST_SUITE=1 -DCGAL_USE_GMPXX=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_KEYWORDS -DQT_OPENGLWIDGETS_LIB -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -I/home/cgal_tester/build/src/cmake/platforms/ArchLinux-clang/test/Generator_Demo -I/mnt/testsuite/test/Generator_Demo -I/home/cgal_tester/build/src/cmake/platforms/ArchLinux-clang/include -I/mnt/testsuite/include -I/home/cgal_tester/build/src/cmake/platforms/ArchLinux-clang/test/AABB_tree_Demo -isystem /home/cgal_tester/build/src/cmake/platforms/ArchLinux-clang/test/Generator_Demo/Generator_2_autogen/include -isystem /usr/include/qt6/QtCore -isystem /usr/include/qt6 -isystem /usr/lib/qt6/mkspecs/linux-g++ -isystem /usr/include/qt6/QtOpenGLWidgets -isystem /usr/include/qt6/QtOpenGL -isystem /usr/include/qt6/QtGui -isystem /usr/include/qt6/QtWidgets -Wall  -fno-direct-access-external-data -MD -MT test/Generator_Demo/CMakeFiles/Generator_2.dir/Generator_2.cpp.o -MF CMakeFiles/Generator_2.dir/Generator_2.cpp.o.d -o CMakeFiles/Generator_2.dir/Generator_2.cpp.o -c /mnt/testsuite/test/Generator_Demo/Generator_2.cpp
In file included from /mnt/testsuite/test/Generator_Demo/Generator_2.cpp:27:
In file included from /mnt/testsuite/include/CGAL/Qt/DemosMainWindow.h:130:
/mnt/testsuite/include/CGAL/Qt/DemosMainWindow_impl.h:224:3: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
  224 |   about_CGAL.open(QIODevice::ReadOnly);
      |   ^~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
1 warning generated.
```


https://cgal.geometryfactory.com/CGAL/testsuite/CGAL-6.2-Ic-36/Generator_Demo/TestReport_gimeno_ArchLinux-clang.gz

## Release Management

* Affected package(s): `GraphicsView`
* Issue(s) solved (if any): n/a
* Feature/Small Feature (if any): n/a
* License and copyright ownership: no change
This commit is contained in:
Sebastien Loriot 2025-11-19 14:41:07 +01:00 committed by GitHub
commit 2f9854b422
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 123 additions and 150 deletions

View File

@ -221,7 +221,10 @@ void
DemosMainWindow::popupAboutBox(QString title, QString html_resource_name)
{
QFile about_CGAL(html_resource_name);
about_CGAL.open(QIODevice::ReadOnly);
if (!about_CGAL.open(QIODevice::ReadOnly)) {
QMessageBox::warning(this, tr("Error"), tr("Could not open resource file: %1").arg(html_resource_name));
return;
}
QString about_CGAL_txt = QTextStream(&about_CGAL).readAll();
#ifdef CGAL_VERSION_STR
QString cgal_version(CGAL_VERSION_STR);

View File

@ -63,9 +63,6 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(T3_demo)
include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
cgal_add_compilation_test(T3_demo)
else(CGAL_Qt6_FOUND AND Qt6_FOUND)
set(TRIANGULATION_3_MISSING_DEPS "")

View File

@ -209,31 +209,3 @@ void MainWindow::on_actionClear_Scene_triggered()
// update viewer
Q_EMIT( sceneChanged() );
}
void MainWindow::popupAboutCGAL()
{
// read contents from .html file
QFile about_CGAL(":/documentation/documentation/about_CGAL.html");
about_CGAL.open(QIODevice::ReadOnly|QIODevice::Text);
QString about_CGAL_txt = QTextStream(&about_CGAL).readAll();
// popup a message box
QMessageBox mb(QMessageBox::NoIcon,
tr("About CGAL..."),
about_CGAL_txt,
QMessageBox::Ok,
this);
// set links to be accessible by mouse or keyboard
QLabel* mb_label = mb.findChild<QLabel*>("qt_msgbox_label");
if(mb_label) {
mb_label->setTextInteractionFlags(mb_label->textInteractionFlags() |
::Qt::LinksAccessibleByMouse |
::Qt::LinksAccessibleByKeyboard);
} else {
std::cerr << "Cannot find child \"qt_msgbox_label\" in QMessageBox\n"
<< " with Qt version " << QT_VERSION_STR << "!\n";
}
mb.exec();
}

View File

@ -36,9 +36,6 @@ public Q_SLOTS:
// show menu
void on_actionClear_Scene_triggered();
// about menu
void popupAboutCGAL();
Q_SIGNALS:
void sceneChanged();

View File

@ -25,6 +25,9 @@ int main(int argc, char** argv)
app.setOrganizationName("INRIA");
app.setApplicationName("3D Triangulation Demo");
// Import resources from libCGALQt (Qt6).
CGAL_QT_INIT_RESOURCES;
MainWindow mw;
mw.show();

View File

@ -183,13 +183,13 @@ void Viewer::compile_shaders()
"} \n"
"\n"
};
QOpenGLShader *vertex_shader = new QOpenGLShader(QOpenGLShader::Vertex);
QOpenGLShader *vertex_shader = new QOpenGLShader(QOpenGLShader::Vertex, this);
if(!vertex_shader->compileSourceCode(vertex_source))
{
std::cerr<<"Compiling vertex source FAILED"<<std::endl;
}
QOpenGLShader *fragment_shader= new QOpenGLShader(QOpenGLShader::Fragment);
QOpenGLShader *fragment_shader= new QOpenGLShader(QOpenGLShader::Fragment, this);
if(!fragment_shader->compileSourceCode(fragment_source))
{
std::cerr<<"Compiling fragmentsource FAILED"<<std::endl;
@ -258,14 +258,14 @@ void Viewer::compile_shaders()
"} \n"
"\n"
};
QOpenGLShader *vertex_shader_spheres = new QOpenGLShader(QOpenGLShader::Vertex);
QOpenGLShader *vertex_shader_spheres = new QOpenGLShader(QOpenGLShader::Vertex, this);
if(!vertex_shader_spheres->compileSourceCode(vertex_source_spheres))
{
std::cerr<<"Compiling vertex source FAILED"<<std::endl;
}
QOpenGLShader *fragment_shader_spheres= new QOpenGLShader(QOpenGLShader::Fragment);
QOpenGLShader *fragment_shader_spheres= new QOpenGLShader(QOpenGLShader::Fragment, this);
if(!fragment_shader_spheres->compileSourceCode(fragment_source_spheres))
{
std::cerr<<"Compiling fragmentsource FAILED"<<std::endl;
@ -312,7 +312,7 @@ void Viewer::compile_shaders()
QOpenGLShader *vertex_shader_cylinders = new QOpenGLShader(QOpenGLShader::Vertex);
QOpenGLShader *vertex_shader_cylinders = new QOpenGLShader(QOpenGLShader::Vertex, this);
if(!vertex_shader_cylinders->compileSourceCode(vertex_source_cylinders))
{
std::cerr<<"Compiling vertex source FAILED"<<std::endl;
@ -1628,7 +1628,7 @@ void Viewer::draw()
}
void Viewer::drawVertex(const Point_3& p, std::vector<float> *vertices)
void Viewer::drawVertex(const Point_3& p, Coords_ptr& vertices)
{
vertices->push_back(p.x()); vertices->push_back(p.y()); vertices->push_back(p.z());
@ -1636,13 +1636,13 @@ void Viewer::drawVertex(const Point_3& p, std::vector<float> *vertices)
}
void Viewer::drawEdge(const Point_3& from, const Point_3& to, std::vector<float> *vertices)
void Viewer::drawEdge(const Point_3& from, const Point_3& to, Coords_ptr& vertices)
{
vertices->push_back( from.x()); vertices->push_back(from.y()); vertices->push_back(from.z());
vertices->push_back( to.x()); vertices->push_back(to.y()); vertices->push_back(to.z());
}
void Viewer::drawFacet(const Triangle_3& t, std::vector<float> *vertices)
void Viewer::drawFacet(const Triangle_3& t, Coords_ptr& vertices)
{
Point_3 p0 = t.vertex(0);
Point_3 p1 = t.vertex(1);
@ -2482,7 +2482,7 @@ void Viewer::incremental_insert() {
}
void Viewer::draw_cylinder(float R, int prec, std::vector<float> *vertices, std::vector<float> *normals)
void Viewer::draw_cylinder(float R, int prec, Coords_ptr& vertices, Coords_ptr& normals)
{
vertices->resize(0);
normals->resize(0);
@ -2551,7 +2551,7 @@ void Viewer::draw_cylinder(float R, int prec, std::vector<float> *vertices, std:
}
}
void Viewer::draw_sphere(float R, int prec, std::vector<float> *vertices, std::vector<float> *normals)
void Viewer::draw_sphere(float R, int prec, Coords_ptr& vertices, Coords_ptr& normals)
{
vertices->resize(0);
normals->resize(0);

View File

@ -42,42 +42,41 @@ public:
, m_hasEmptyS(false)
, m_showTrackball(true)
, m_pDlgPrefer(nullptr)
{
pos_emptyFacet = new std::vector<float>();
pos_emptySphere= new std::vector<float>();
points_emptySphere = new std::vector<float>();
pos_points = new std::vector<float>();
pos_newPoint = new std::vector<float>();
pos_selectedVertex = new std::vector<float>();
pos_movingPoint = new std::vector<float>();
pos_queryPoint = new std::vector<float>();
pos_trackBall = new std::vector<float>();
pos_voronoi = new std::vector<float>();
pos_delaunay = new std::vector<float>();
pos_facets = new std::vector<float>();
pos_newFacet = new std::vector<float>();
pos_nearest_neighbor = new std::vector<float>();
points_locationSphere = new std::vector<float>();
points_cylinder = new std::vector<float>();
normals_cylinder = new std::vector<float>();
points_sphere = new std::vector<float>();
points_trackBall = new std::vector<float>();
normals_sphere = new std::vector<float>();
normals_emptySphere = new std::vector<float>();
normals_trackBall= new std::vector<float>();
transfo1_voronoi = new std::vector<float>();
transfo2_voronoi = new std::vector<float>();
transfo3_voronoi = new std::vector<float>();
transfo4_voronoi = new std::vector<float>();
transfo1_delaunay = new std::vector<float>();
transfo2_delaunay = new std::vector<float>();
transfo3_delaunay = new std::vector<float>();
transfo4_delaunay = new std::vector<float>();
incremental_points = new std::vector<float>();
incremental_next_point = new std::vector<float>();
incremental_facet = new std::vector<float>();
incremental_conflict = new std::vector<float>();
}
, pos_emptyFacet{new Coords}
, pos_emptySphere{new Coords}
, points_emptySphere{new Coords}
, pos_points{new Coords}
, pos_newPoint{new Coords}
, pos_selectedVertex{new Coords}
, pos_movingPoint{new Coords}
, pos_queryPoint{new Coords}
, pos_trackBall{ new Coords}
, pos_voronoi{new Coords}
, pos_delaunay{new Coords}
, pos_facets{new Coords}
, pos_newFacet{new Coords}
, pos_nearest_neighbor{new Coords}
, points_locationSphere{new Coords}
, points_cylinder{new Coords}
, normals_cylinder{new Coords}
, points_sphere{new Coords}
, points_trackBall{new Coords}
, normals_sphere{new Coords}
, normals_emptySphere{new Coords}
, normals_trackBall{new Coords}
, transfo1_voronoi{new Coords}
, transfo2_voronoi{new Coords}
, transfo3_voronoi{new Coords}
, transfo4_voronoi{new Coords}
, transfo1_delaunay{new Coords}
, transfo2_delaunay{new Coords}
, transfo3_delaunay{new Coords}
, transfo4_delaunay{new Coords}
, incremental_points{new Coords}
, incremental_next_point{new Coords}
, incremental_facet{new Coords}
, incremental_conflict{new Coords}
{}
~Viewer()
{
@ -269,12 +268,15 @@ protected:
QString helpString() const;
private:
using Coords = std::vector<float>;
using Coords_ptr = std::unique_ptr<std::vector<float>>;
// draw a 3d effect vertex
void drawVertex(const Point_3& p, std::vector<float> *vertices);
void drawVertex(const Point_3& p, Coords_ptr& vertices);
// draw a 3d effect edge
void drawEdge(const Point_3& from, const Point_3 &to, std::vector<float> *vertices);
void drawEdge(const Point_3& from, const Point_3 &to, Coords_ptr& vertices);
// draw a facet
void drawFacet(const Triangle_3& t, std::vector<float> *vertices);
void drawFacet(const Triangle_3& t, Coords_ptr& vertices);
// test whether the give 3D point is on the sphere
inline bool isOnSphere( const Point_3 & pt ) {
return ( (pt.x()*pt.x() + pt.y()*pt.y() + pt.z()*pt.z()) == (m_fRadius*m_fRadius) );
@ -362,42 +364,41 @@ private:
bool are_buffers_initialized;
bool extension_is_found;
std::vector<float> *pos_emptyFacet;
std::vector<float> *pos_emptySphere;
std::vector<float> *points_emptySphere;
std::vector<float> *pos_points;
std::vector<float> *pos_newPoint;
std::vector<float> *pos_selectedVertex;
std::vector<float> *pos_movingPoint;
std::vector<float> *pos_queryPoint;
std::vector<float> *pos_trackBall;
std::vector<float> *points_trackBall;
std::vector<float> *pos_voronoi;
std::vector<float> *pos_delaunay;
std::vector<float> *pos_facets;
std::vector<float> *pos_newFacet;
std::vector<float> *pos_nearest_neighbor;
std::vector<float> *points_locationSphere;
std::vector<float> *points_cylinder;
std::vector<float> *normals_cylinder;
std::vector<float> *points_sphere;
std::vector<float> *normals_sphere;
std::vector<float> *normals_emptySphere;
std::vector<float> *normals_trackBall;
std::vector<float> *transfo1_voronoi;
std::vector<float> *transfo2_voronoi;
std::vector<float> *transfo3_voronoi;
std::vector<float> *transfo4_voronoi;
std::vector<float> *transfo1_delaunay;
std::vector<float> *transfo2_delaunay;
std::vector<float> *transfo3_delaunay;
std::vector<float> *transfo4_delaunay;
std::vector<float> *incremental_points;
std::vector<float> *incremental_next_point;
std::vector<float> *incremental_facet;
std::vector<float> *incremental_conflict;
//picking
Coords_ptr pos_emptyFacet;
Coords_ptr pos_emptySphere;
Coords_ptr points_emptySphere;
Coords_ptr pos_points;
Coords_ptr pos_newPoint;
Coords_ptr pos_selectedVertex;
Coords_ptr pos_movingPoint;
Coords_ptr pos_queryPoint;
Coords_ptr pos_trackBall;
Coords_ptr pos_voronoi;
Coords_ptr pos_delaunay;
Coords_ptr pos_facets;
Coords_ptr pos_newFacet;
Coords_ptr pos_nearest_neighbor;
Coords_ptr points_locationSphere;
Coords_ptr points_cylinder;
Coords_ptr normals_cylinder;
Coords_ptr points_sphere;
Coords_ptr points_trackBall;
Coords_ptr normals_sphere;
Coords_ptr normals_emptySphere;
Coords_ptr normals_trackBall;
Coords_ptr transfo1_voronoi;
Coords_ptr transfo2_voronoi;
Coords_ptr transfo3_voronoi;
Coords_ptr transfo4_voronoi;
Coords_ptr transfo1_delaunay;
Coords_ptr transfo2_delaunay;
Coords_ptr transfo3_delaunay;
Coords_ptr transfo4_delaunay;
Coords_ptr incremental_points;
Coords_ptr incremental_next_point;
Coords_ptr incremental_facet;
Coords_ptr incremental_conflict;
//pickin
QMap<float, int> picked_IDs;
QPoint picking_pos;
@ -414,8 +415,8 @@ private:
void compute_elements();
void attrib_buffers(CGAL::QGLViewer*);
void compile_shaders();
void draw_cylinder(float R, int prec, std::vector<float> *vertices, std::vector<float> *normals);
void draw_sphere(float R, int prec, std::vector<float> *vertices, std::vector<float> *normals);
void draw_cylinder(float R, int prec, Coords_ptr& vertices, Coords_ptr& normals);
void draw_sphere(float R, int prec, Coords_ptr& vertices, Coords_ptr& normals);
};
#endif