[v1] apps: qcam: Show `QImageWriter` errors
diff mbox series

Message ID 20260216145410.495478-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1] apps: qcam: Show `QImageWriter` errors
Related show

Commit Message

Barnabás Pőcze Feb. 16, 2026, 2:54 p.m. UTC
When saving the current iamge, `QImageWriter::write()` may fail for various
reasons. However, this is currently not reported in any way.

Use a simple `QMessageBox` to report the issues.

Link: https://gitlab.freedesktop.org/camera/libcamera/-/issues/313
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/apps/qcam/main_window.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Kieran Bingham Feb. 16, 2026, 7:18 p.m. UTC | #1
Quoting Barnabás Pőcze (2026-02-16 14:54:10)
> When saving the current iamge, `QImageWriter::write()` may fail for various
> reasons. However, this is currently not reported in any way.
> 
> Use a simple `QMessageBox` to report the issues.
> 
> Link: https://gitlab.freedesktop.org/camera/libcamera/-/issues/313
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Already worth adding indeed.


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/apps/qcam/main_window.cpp | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
> index 96a2d5090..5a88c5aa8 100644
> --- a/src/apps/qcam/main_window.cpp
> +++ b/src/apps/qcam/main_window.cpp
> @@ -18,6 +18,7 @@
>  #include <QFileDialog>
>  #include <QImage>
>  #include <QImageWriter>
> +#include <QMessageBox>
>  #include <QMutexLocker>
>  #include <QStandardPaths>
>  #include <QStringList>
> @@ -637,7 +638,8 @@ void MainWindow::saveImageAs()
>  
>         QImageWriter writer(filename);
>         writer.setQuality(95);
> -       writer.write(image);
> +       if (!writer.write(image))
> +               QMessageBox::warning(this, "Failed to save image", writer.errorString());
>  }
>  
>  void MainWindow::captureRaw()
> -- 
> 2.53.0
>

Patch
diff mbox series

diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
index 96a2d5090..5a88c5aa8 100644
--- a/src/apps/qcam/main_window.cpp
+++ b/src/apps/qcam/main_window.cpp
@@ -18,6 +18,7 @@ 
 #include <QFileDialog>
 #include <QImage>
 #include <QImageWriter>
+#include <QMessageBox>
 #include <QMutexLocker>
 #include <QStandardPaths>
 #include <QStringList>
@@ -637,7 +638,8 @@  void MainWindow::saveImageAs()
 
 	QImageWriter writer(filename);
 	writer.setQuality(95);
-	writer.write(image);
+	if (!writer.write(image))
+		QMessageBox::warning(this, "Failed to save image", writer.errorString());
 }
 
 void MainWindow::captureRaw()