Lab: Use Results to Avoid Warning (#9156)

## Summary of Changes

Check that `open()` worked to avoid warnings
[here](https://cgal.geometryfactory.com/CGAL/testsuite/CGAL-6.2-Ic-50/Lab_Demo/TestReport_cgaltest_ArchLinux-clang-CXX20-Release.gz).

## Release Management

* Affected package(s): Lab

* License and copyright ownership: unchanged
This commit is contained in:
Sebastien Loriot 2025-12-03 11:52:48 +01:00 committed by GitHub
commit def6c38d76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 27 deletions

View File

@ -1795,8 +1795,8 @@ bool MainWindow::loadScript(QFileInfo info)
QString program; QString program;
QString filename = info.absoluteFilePath(); QString filename = info.absoluteFilePath();
QFile script_file(filename); QFile script_file(filename);
script_file.open(QIODevice::ReadOnly); bool success = script_file.open(QIODevice::ReadOnly);
if(!script_file.isReadable()) { if((! success) || (!script_file.isReadable())) {
throw std::ios_base::failure(script_file.errorString().toStdString()); throw std::ios_base::failure(script_file.errorString().toStdString());
} }
program = script_file.readAll(); program = script_file.readAll();
@ -2747,9 +2747,9 @@ void MainWindow::exportStatistics()
if(filename.isEmpty()) if(filename.isEmpty())
return; return;
QFile output(filename); QFile output(filename);
output.open(QIODevice::WriteOnly | QIODevice::Text); bool success = output.open(QIODevice::WriteOnly | QIODevice::Text);
if(!output.isOpen()){ if((! success) || (!output.isOpen())){
qDebug() << "- Error, unable to open" << "outputFilename" << "for output"; qDebug() << "- Error, unable to open" << "outputFilename" << "for output";
} }
QTextStream outStream(&output); QTextStream outStream(&output);

View File

@ -93,7 +93,7 @@ bool Camera_positions_list::save(QString filename) {
if(m_model->rowCount() <1) if(m_model->rowCount() <1)
return false; return false;
QFile file(filename); QFile file(filename);
file.open(QIODevice::WriteOnly); if(file.open(QIODevice::WriteOnly)){
QTextStream out(&file); QTextStream out(&file);
for(int i = 0; i < m_model->rowCount(); ++i) for(int i = 0; i < m_model->rowCount(); ++i)
{ {
@ -105,6 +105,8 @@ bool Camera_positions_list::save(QString filename) {
} }
file.close(); file.close();
return true; return true;
}
return false;
} }
void Camera_positions_list::on_saveButton_pressed() void Camera_positions_list::on_saveButton_pressed()
@ -129,8 +131,10 @@ void Camera_positions_list::on_openButton_pressed()
void Camera_positions_list::load(QString filename) { void Camera_positions_list::load(QString filename) {
QFile file(filename); QFile file(filename);
if(file.open(QIODevice::ReadOnly)){
std::clog << "Loading camera positions " << qPrintable(filename) << std::endl; std::clog << "Loading camera positions " << qPrintable(filename) << std::endl;
file.open(QIODevice::ReadOnly);
QTextStream input(&file); QTextStream input(&file);
while(!input.atEnd()) { while(!input.atEnd()) {
QString text = input.readLine(1000); QString text = input.readLine(1000);
@ -143,6 +147,9 @@ void Camera_positions_list::load(QString filename) {
Three::activeViewer()->dumpFrame(frame)); Three::activeViewer()->dumpFrame(frame));
} }
} }
}else {
std::clog << "Loading camera positions " << qPrintable(filename) << " failed" << std::endl;
}
} }
void Camera_positions_list::on_frontButton_pressed() void Camera_positions_list::on_frontButton_pressed()